Skip to content

Vite HMR websocket is not working after upgrading nuxt from 3.6.5 to 3.7.4 #251

@nikowonde

Description

@nikowonde

I am running nuxt over proxy to custom local domain and it was previously working correctly with protocol and host defined in vite.server.hmr config. In 3.6.5 defined protocol and host were used and everything worked correctly.

In nuxt.config

vite: {
    server: {
      hmr: {
        protocol: 'ws',
        host: 'localhost',
      },
    },
  },

After upgrading to 3.7.4 vite/dist/client is resolving SERVER_HOST to localhost:undefined/[buildAssetsDir] and both HMR_PROTOCOL and HMR_PORT are being resolved to null which is causing socketHost to default to fallback values which are derived from properties in window.location? and with these values (and maybe because of proxy usage) it's throwing an error Illegal or invalid string for new Websocket('wss://proxyurl:/[buildAssetsDir]') call in setupWebSocket func.

Can't really provide reproduction at this time as I do not know how I would approach creating one with usable proxy.

I got tip from @danielroe to downgrade nuxi to 3.6.5 and that seems to fix it for now.

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