Skip to content

AutoReload hardcodes websocket host address to localhost #4638

@kh-aeros

Description

@kh-aeros

Describe the bug
When using cargo-leptos and the watch command, the <AutoReload> component injects some JS, and creates a WebSocket to ws://localhost:3001/live_reload. Unfortunately for me, I am running the server within a DevContainer, and accessing the site on the Host machine. I have forwarded the necessary ports in the Dockefile so that I can access the website (bound to 0.0.0.0:8000 in this case), but because the hot-reload script uses let host = window.location.hostname; to determine the root URL, when accessing the website from the Host web browser, the Console will repeatedly report:

(index):481  WebSocket connection to 'ws://localhost:3001/live_reload' failed: Connection closed before receiving a handshake response
(index):506  Live-reload disconnected. Reconnecting...

Ideally, the URL for hot-reloading should be the same as defined by leptos_options.site_addr.

Leptos Dependencies

leptos = { version = "0.8", default-features = false }
leptos_meta = "0.8"
leptos_router = "0.8"

Next Steps

  • I will make a PR
  • I would like to make a PR, but need help getting started
  • I want someone else to take the time to fix this
  • This is a low priority for me and is just shared for your information

Additional context
None

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