Skip to content

Websockets can be proxied, but the method is undocumented #1013

Description

@dceddia

If you are reporting a bug, please fill in below. Otherwise feel free to remove this template entirely.

Can you reproduce the problem with latest npm?

Yes

Description

I was trying to proxy Websockets through the "proxy" feature built into CRA. With a proxy setting of "http://localhost:4000" (an express server), the Websocket doesn't work. However, with a URL of "ws://localhost:4000", the Websockets do work! 😄 (along with regular HTTP requests). According to the underlying http-proxy-middleware library, this is supported.

This is great. So why file this issue? There are 2 conflicting pieces of info in CRA:

  • This comment in start.js implies Websockets are supported.
  • The README / User Guide says "Currently the proxy option only handles HTTP requests, and it won’t proxy WebSocket connections."

I'd be happy to submit a PR with these changes.

Expected behavior

The README should advertise Websocket proxying with the "ws://" prefix, and the comment in start.js should probably be updated to mention the prefix too.

Actual behavior

The current docs about Websockets undersell the actual functionality 😄

Environment

This isn't environment-related.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions