Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quick fix for HTTPS port from env not working properly by allowing env HMR_PORT alongside env PORT #9715

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/core/core/src/resolveOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export default async function resolveOptions(
};

let port = determinePort(initialOptions.serveOptions, env.PORT);
let hmrPort = determinePort(initialOptions.hmrOptions, env.HMR_PORT);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I suggest using env.HMR_PORT?.length ? env.HMR_PORT : env.PORT. As such, when only setting env.PORT, it would allow for HMR to use the same port when env.HMR_PORT isn't set. This is aligned with the behavior of the CLI, where --port sets both the main and HMR port.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.


return {
config: getRelativeConfigSpecifier(
Expand All @@ -162,7 +163,13 @@ export default async function resolveOptions(
env,
mode,
shouldAutoInstall: initialOptions.shouldAutoInstall ?? false,
hmrOptions: initialOptions.hmrOptions ?? null,
hmrOptions:
initialOptions.hmrOptions != null
? {
...initialOptions.hmrOptions,
port: hmrPort,
}
: null,
shouldBuildLazily,
lazyIncludes,
lazyExcludes,
Expand Down