Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !12774

Fix argument `allowedHost`

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/Manc/patch into main 2 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: Manc

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.

Compare
  • version 1
    b0b851f3
    2 years ago

  • main (HEAD)

and
  • latest version
    b0b851f3
    1 commit, 2 years ago

  • version 1
    b0b851f3
    1 commit, 2 years ago

1 file
+ 1
- 1

    Preferences

    File browser
    Compare changes
packages/react-scripts/scripts/start.js
+ 1
- 1
  • View file @ 68ea53b2

  • Edit in single-file editor

  • Open in Web IDE


@@ -116,7 +116,7 @@ checkBrowsers(paths.appPath, isInteractive)
);
// Serve webpack assets generated by the compiler over a web server.
const serverConfig = {
...createDevServerConfig(proxyConfig, urls.lanUrlForConfig),
...createDevServerConfig(proxyConfig, HOST),
host: HOST,
port,
};
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
2
CLA Signed tag: bug fix
2
CLA Signed tag: bug fix
    Assign labels
  • Manage project labels

Milestone
1.0.8
1.0.8
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference: facebook/create-react-app!2596
Source branch: github/fork/Manc/patch

Menu

Explore Projects Groups Snippets