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

Unable to start dev server with domain configured by PAC (proxy auto-config) #3789

Closed
levrik opened this issue Jan 14, 2018 · 6 comments
Closed

Comments

@levrik
Copy link
Contributor

levrik commented Jan 14, 2018

I'm using a PAC (proxy auto-config) file to redirect all domains ending with .local to a local development proxy without messing around with my hosts file.
This seems to don't play well when using the HOST environment variable in cra.

image

Settings DANGEROUSLY_DISABLE_HOST_CHECK to true has no effect.

Environment

  1. node -v: v8.9.0
  2. npm -v: 4.0.5
  3. yarn --version (if you use Yarn): 1.3.2
  4. npm ls react-scripts (if you haven’t ejected): 1.0.17

Then, specify:

  1. Operating system: Windows 10

Steps to Reproduce

  1. Configure a URL to an PAC file with the following content:
function FindProxyForURL (url, host) {
  if (dnsDomainIs(host, '.local')) {
    return 'PROXY 127.0.0.1:2000';
  }

  return 'DIRECT';
}
  1. Setup an reverse proxy (nginx, whatever) to listen on port 2000 with a .local domain configured with the cra dev server as target.
  2. Configure HOST to your .local domain.
  3. Try to start cra. It gets stuck for some time before showing the above error.
@Timer
Copy link
Contributor

Timer commented Jan 14, 2018

To work around this, add HOST=localhost to your .env file.

@gaearon
Copy link
Contributor

gaearon commented Jan 14, 2018

Is there anything we can do to improve this?

@levrik
Copy link
Contributor Author

levrik commented Jan 14, 2018

@Timer Ah, awesome. HOST=localhost together with DANGEROUSLY_DISABLE_HOST_CHECK=true is a good workaround.

@gaearon I think cra would need to be able to resolve domain names via PAC.
Maybe this could help? https://github.com/TooTallNate/node-pac-resolver
Would still need to get the PAC file out of the system settings.

If this is something that you would like to have supported by cra I could look into it. I think the resolving part is easy with module mentioned above. Just need to find out how to access the system setting on other platforms. On Windows it's possible via registry and Windows API. Not sure if cra should ship native Node addons tho.

Mentioning the workaround in the docs would be a first good step I think.

@Timer
Copy link
Contributor

Timer commented Jan 14, 2018

Our docs mention HOST is respected.

This message would've prevented this issue: #3730, so we should probably merge it. 😄

@levrik
Copy link
Contributor Author

levrik commented Jan 14, 2018

@Timer no. HOST was set on purpose because I set the proxy option in the package.json and cra complained about the invalid host header.

@stale
Copy link

stale bot commented Nov 2, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs.

@stale stale bot added the stale label Nov 2, 2018
@Timer Timer closed this as completed Nov 2, 2018
@lock lock bot locked and limited conversation to collaborators Jan 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants