Skip to content
GitLab
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
  • Issues
  • #10878
Closed
Open
Issue created Apr 25, 2021 by Administrator@rootContributor

Proxying WebSocket requests is broken

Created by: minus7

Describe the bug

Setting the proxy field in package.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 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

  1. Add a breakpoint or console.log in the onProxyReq callback mentioned above.
  2. yarn start any created project with a configured proxy
  3. Open a websocket connection
  4. 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.

Assignee
Assign to
Time tracking