nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.13k stars 628 forks source link

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

Open ydnar opened 1 year ago

ydnar commented 1 year ago

Environment

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

jackismissing commented 1 year ago

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

yancyknight commented 1 year ago

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

Barbapapazes commented 1 year ago

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

josvos commented 1 year ago

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,
  },