For websocket requests, the onProxyReq hook is not executed and thus the original Origin is sent to the target server. The target server will likely reject the request because Host and Origin mismatch (Gorilla websockts in my case). To also patch Origin for websocket requests, the onProxyReqWs hook has to be specified additionally.
Steps to reproduce
Add a breakpoint or console.log in the onProxyReq callback mentioned above.
yarn start any created project with a configured proxy
Open a websocket connection
See nothing getting logged because only onProxyReqWs is called for websocket connections.
Expected behavior
Origin and Host are equal for proxied websocket requests (e.g. http://localhost:8080).
Actual behavior
Origin is the original header sent by the browser (e.g. http://localhost:3000) while Host is changed (e.g. http://localhost:8080).
--
Note: I'd have sent a patch, but I refuse to sign the CLA.
Describe the bug
Setting the
proxy
field inpackage.json
proxies normal HTTP requests and WebSocket requests.For normal requests, the
Origin
header is patched to equal the target host (added in #1212).For websocket requests, the
onProxyReq
hook is not executed and thus the originalOrigin
is sent to the target server. The target server will likely reject the request becauseHost
andOrigin
mismatch (Gorilla websockts in my case). To also patchOrigin
for websocket requests, theonProxyReqWs
hook has to be specified additionally.Steps to reproduce
console.log
in theonProxyReq
callback mentioned above.yarn start
any created project with a configured proxyonProxyReqWs
is called for websocket connections.Expected behavior
Origin
andHost
are equal for proxied websocket requests (e.g.http://localhost:8080
).Actual behavior
Origin
is the original header sent by the browser (e.g.http://localhost:3000
) whileHost
is changed (e.g.http://localhost:8080
).--
Note: I'd have sent a patch, but I refuse to sign the CLA.