Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
perty opened this issue May 28, 2021 · 0 comments

Comments

@perty
Copy link

perty commented May 28, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant