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

Fix argument allowedHost #12774

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix argument allowedHost #12774

wants to merge 1 commit into from

Conversation

Manc
Copy link

@Manc Manc commented Oct 13, 2022

This PR fixes issues #12304 and #11762 – “react-scripts start fails when both HOST and proxy are defined”.

Steps to verify the issue

  • Add a proxy in package.json of a new project (if verifying within the monorepo code, use packages/react-scripts/package.json).
  • Set a HOST environment variable and run the start script, e.g: HOST=example.local yarn run start
  • The script will fail with error message: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. options.allowedHosts[0] should be a non-empty string.

After applying this patch, the script will run as expected, setting the allowedHost property of the Webpack config to the given hostname.

Explanation

The function createDevServerConfig expects the hostname as string for its second argument, but instead of HOST, urls.lanUrlForConfig is provided and its value is undefined.

It appears, this bug has been in introduced all the way back in 2017.

@Manc Manc requested a review from mrmckeb as a code owner October 13, 2022 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant