purescript-halogen / purescript-halogen-template

Template project for getting started with Halogen
Apache License 2.0
128 stars 56 forks source link

Auto refresh breaks when listening on all interfaces #42

Closed benjamin-thomas closed 1 year ago

benjamin-thomas commented 1 year ago

Hello!

Trying a bit of PureScript and Halogen today :)

Launching this command, I can access the web server fine from another device on my local network.

npm run serve -- --host=0.0.0.0

However, auto-refreshing the page won't work because the websocket tries to connect to the wrong address.

I'm not sure who owns that code but maybe there's something you could do about it?

runtime-c0fb628751bc271e.js:94         
WebSocket connection to 'ws://0.0.0.0:1234/' failed: Error in connection establishment: net::ERR_ADDRESS_INVALID

Hacky workaround to grab my local IP:

npm run serve -- --host=$(hostname -I | awk '{print $1}')

But that breaks localhost unfortunately :(

A minor nuisance

garyb commented 1 year ago

I guess this is something to do with parcel since that's what is behind the serve command, but I don't know anything about really. I'd be a little surprised if it can't be configured to support this case.

For serving with auto-reloading in my own projects I've used live-server which has worked well enough for the most part.

benjamin-thomas commented 1 year ago

Ah it's a parcel bug indeed. And fixed in the latest version 2.8.3. See this PR: https://github.com/parcel-bundler/parcel/pull/7357

Closing this, sorry for the bother :)