Skip to content

fix(websocket): client url for development with proxy #3343

@dargmuesli

Description

@dargmuesli

Environment

irrelevant

Version

v3.5.1

Reproduction

not possible to replicate service structure in stackblitz

Description

When running Nuxt development behind a reverse proxy like traefik, the client websocket's client URL does not necessarily match the websocket server URL. For instance, the reverse proxy can terminate SSL while Nuxt runs plain http, making the current websocket implementation offer ws: as protocol while it should be wss:.

The server can't know under which address it's offered to the client, so the client side needs to device whether to try wss or ws first, depending on the mode Nuxt is served to it. The same goes for the hostname.

Actually, vite's hmr server connection is constructed in a similar fashion, that's why it works right away in all contexts:

Image

Additional context

I'll submit a PR right away: #3344

Actually, if anyone wants to test as setup with a reverse proxy, content.watch.hostname needs to be set to 0.0.0.0, but that's up to the user project to define, not in this module's source.

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions