Skip to content

[Question] How to prevent rewrite of websocket url to "sockjs-node/[random]/[random]/" #593

@perty

Description

@perty

Is this a bug report?

No, this is a call for help.

I have a small script to bridge between Elm and WebSockets. I have done this in other Elm apps which do not use create-elm-app without problem. However, when I use create-elm-app, the url I provide gets rewritten.

const ws = new WebSocket(protocol + "//" + host + "/websocket");

Results in:
WebSocket connection to 'ws://localhost:3000/sockjs-node/631/03d4psaf/websocket' failed: WebSocket is closed before the connection is established.

As can be seen, something is interfering with setting up the WebSocket. The url is prepended with a partially random string.

After googling, I suspect this has something to do with Webpack which uses SockJs for hot reloading. This might be therefore be unsolvable, it is just how JavaScript works, if someone decides to intercept something, then everyone is hit.

But if I am wrong, I really like to know how to avoid the URL rewrite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions