You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: packages/react-scripts/template/README.md
+27
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,7 @@ You can find the most recent version of this guide [here](https://github.com/fac
42
42
-[Node](#node)
43
43
-[Ruby on Rails](#ruby-on-rails)
44
44
-[Proxying API Requests in Development](#proxying-api-requests-in-development)
45
+
-["Invalid Host Header" Errors After Configuring Proxy](#invalid-host-header-errors-after-configuring-proxy)
45
46
-[Configuring the Proxy Manually](#configuring-the-proxy-manually)
46
47
-[Using HTTPS in Development](#using-https-in-development)
47
48
-[Generating Dynamic `<meta>` Tags on the Server](#generating-dynamic-meta-tags-on-the-server)
@@ -897,6 +898,32 @@ If the `proxy` option is **not** flexible enough for you, alternatively you can:
897
898
* Enable CORS on your server ([here’s how to do it for Express](http://enable-cors.org/server_expressjs.html)).
898
899
* Use [environment variables](#adding-custom-environment-variables) to inject the right server host and port into your app.
899
900
901
+
### "Invalid Host Header" Errors After Configuring Proxy
902
+
903
+
When you enable the `proxy` option, you opt into a more strict set of host checks. This is necessary because leaving the backend open to remote hosts makes your computer vulnerable to DNS rebinding attacks. The issue is explained in [this article](https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a) and [this issue](https://github.com/webpack/webpack-dev-server/issues/887).
904
+
905
+
This shouldn’t affect you when developing on `localhost`, but if you develop remotely like [described here](https://github.com/facebookincubator/create-react-app/issues/2271), you will see this error in the browser after enabling the `proxy` option:
906
+
907
+
>Invalid Host header
908
+
909
+
To work around it, you can specify your public development host in a file called `.env.development` in the root of your project:
910
+
911
+
```
912
+
HOST=mypublicdevhost.com
913
+
```
914
+
915
+
If you restart the development server now and load the app from the specified host, it should work.
916
+
917
+
If you are still having issues or if you’re using a more exotic environment like a cloud editor, you can bypass the host check completely by adding a line to `.env.development.local`. **Note that this is dangerous and exposes your machine to remote code execution from malicious websites:**
918
+
919
+
```
920
+
# NOTE: THIS IS DANGEROUS!
921
+
# It exposes your machine to attacks from the websites you visit.
922
+
DANGEROUSLY_DISABLE_HOST_CHECK=true
923
+
```
924
+
925
+
We don’t recommend this approach.
926
+
900
927
### Configuring the Proxy Manually
901
928
902
929
>Note: this feature is available with `react-scripts@1.0.0` and higher.
0 commit comments