Don't use hard-coded localhost for websocket
See original GitHub issueDescribe the bug
localhost is hard-coded here: https://github.com/nvh95/jest-preview/blob/v0.3.1/cli/server/ws-client.js#L4
This makes remote development a little more finicky. I’m running jest-preview in a remote server, and want to use my laptop’s browser to visit the jest preview dashboard. Right now the dashboard loads fine, but since the websocket client tries to hit localhost, the auto-reloading doesn’t work. I haven’t tried it, but I believe a SSH tunnel would work around the issue, but would prefer not have to set that up.
I manually replaced localhost with my remote server’s address, and things worked great
Screenshots
N/A
Reproduce
On a remote server with ports 3336 and 3337 available, run yarn jest-preview
. Attempt to visit the remote IP at port 3336. Note that the JS console says that it tries to reach localhost:3337
Expected behavior
I think the simplest and almost-strictly-better than current state is to use the browser host (window.host or whatever) as the hostname. For people using localhost, things will continue to work like before, while those using non-localhost should now automatically work, assuming that port 3337 is reachable.
There is an edge case for people who use 3336 with a remote hostname, but need a localhost 3337 for some reason…
Environment (please complete the following information)
Running yarn jest-preview on a remote server, 0.3.1
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Looks good to me, thank you!
I will give the new version a try today, thank you. The diff does look good to me!