Skip to content

Commit

Permalink
fix: address already in use
Browse files Browse the repository at this point in the history
fix: address already in use
  • Loading branch information
xiaohuoni authored Nov 4, 2024
2 parents 7d9bbb2 + 4c6f623 commit 07c510d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"cors": "^2.8.5",
"express": "^4.21.1",
"express-http-proxy": "^2.1.1",
"get-port-please": "^3.1.2",
"http-proxy-middleware": "^3.0.3",
"pathe": "^1.1.2",
"picocolors": "^1.1.1",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/dev.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { BuildParams } from '@umijs/mako';
import { getPort } from 'get-port-please';
import { build } from './build';
import { DEFAULT_PORT } from './constants';
import { createServer } from './fishkit/server';
Expand All @@ -15,11 +16,12 @@ export interface DevOpts {

export async function dev(opts: DevOpts) {
const port = opts.port || DEFAULT_PORT;
const hmrPort = port + 1;
const _port = await getPort(port);
const hmrPort = await getPort(_port + 1);
const host = opts.host || 'localhost';

await createServer({
port,
port: _port,
hmrPort,
host,
https: opts.https,
Expand Down

0 comments on commit 07c510d

Please sign in to comment.