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
{{ message }}
This repository was archived by the owner on Jan 26, 2019. It is now read-only.
Copy file name to clipboardexpand all lines: packages/react-scripts/template/README.md
+31
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,7 @@ You can find the most recent version of this guide [here](https://github.com/fac
44
44
-[Proxying API Requests in Development](#proxying-api-requests-in-development)
45
45
-["Invalid Host Header" Errors After Configuring Proxy](#invalid-host-header-errors-after-configuring-proxy)
46
46
-[Configuring the Proxy Manually](#configuring-the-proxy-manually)
47
+
-[Configuring a WebSocket Proxy](#configuring-a-websocket-proxy)
47
48
-[Using HTTPS in Development](#using-https-in-development)
48
49
-[Generating Dynamic `<meta>` Tags on the Server](#generating-dynamic-meta-tags-on-the-server)
49
50
-[Pre-Rendering into Static HTML Files](#pre-rendering-into-static-html-files)
@@ -992,6 +993,36 @@ You may also narrow down matches using `*` and/or `**`, to match the path exactl
992
993
}
993
994
```
994
995
996
+
### Configuring a WebSocket Proxy
997
+
998
+
When setting up a WebSocket proxy, there are a some extra considerations to be aware of.
999
+
1000
+
If you’re using a WebSocket engine like [Socket.io](https://socket.io/), you must have a Socket.io server running that you can use as the proxy target. Socket.io will not work with a standard WebSocket server. Specifically, don't expect Socket.io to work with [the websocket.org echo test](http://websocket.org/echo.html).
1001
+
1002
+
There’s some good documentation available for [setting up a Socket.io server](https://socket.io/docs/).
1003
+
1004
+
Standard WebSockets **will** work with a standard WebSocket server as well as the websocket.org echo test. You can use libraries like [ws](https://github.com/websockets/ws) for the server, with [native WebSockets in the browser](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket).
1005
+
1006
+
Either way, you can proxy WebSocket requests manually in `package.json`:
1007
+
1008
+
```js
1009
+
{
1010
+
// ...
1011
+
"proxy": {
1012
+
"/socket": {
1013
+
// Your compatible WebSocket server
1014
+
"target":"ws://<socket_url>",
1015
+
// Tell http-proxy-middleware that this is a WebSocket proxy.
1016
+
// Also allows you to proxy WebSocket requests without an additional HTTP request
0 commit comments