content icon indicating copy to clipboard operation
content copied to clipboard

Websocket fails to connect when testing on non-localhost (e.g. via mobile)

Open ydnar opened this issue 2 years ago • 4 comments

Environment

  • Operating System: Darwin
  • Node Version: v19.5.0
  • Nuxt Version: 3.1.1
  • Nitro Version: 2.0.0
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: modules, vite, runtimeConfig, css, app, hooks, content, i18n
  • Runtime Modules: @nuxt/[email protected], @nuxtjs/[email protected]
  • Build Modules: -

Reproduction

View any Nuxt server in development from another device. Watch the Websocket try and fail to connect, repeatedly.

Describe the bug

The Websocket URL is hard-coded to use localhost as hostname, which means when testing from another device, the Websocket tries to connect and fails repeatedly, spamming the console.

The issue is here: https://github.com/nuxt/content/blob/5f1c1349af774f10b26d250c1cc621f4b9912243/src/module.ts#L657

Additional context

No response

Logs

No response

ydnar avatar Feb 02 '23 20:02 ydnar

I experience the same issue, have you found a workaround?

jackismissing avatar Mar 08 '23 10:03 jackismissing

We are having the same problem, nuxt is running on a remote development server and local browser can't connect to the websocket.

yancyknight avatar May 17 '23 15:05 yancyknight

Hello, can you provide a set up to reproduce this issue?

Barbapapazes avatar Aug 12 '23 08:08 Barbapapazes

I came across the same problem. For whoever this may be useful: adding this to your nuxt.config.ts (inside defineNuxtConfig's parameter object) disables the content watch, in case you don't really need it and want to get rid of the endless loop of websocket errors:

  content: {
    watch: false,
  },

josvos avatar Sep 29 '23 13:09 josvos