VUE中的错误:与ws:// ...加载时中断了与WS:// ...

发布于 2025-01-31 17:27:11 字数 190 浏览 0 评论 0原文

与ws://192.168.1.36:8080/ws的连接中断了页面加载时,

我每秒都会弹出此错误。它要么在我运行“ NPM审核修复”或尝试安装socket.io-client之后开始。有趣的是,这仅发生在Firefox中。我没有任何插座代码,这显然与热重加载有关。构建项目后,它通常没有错误。我谷歌搜索了很多,但没有找到解决这个问题的方法。提前致谢。

The connection to ws://192.168.1.36:8080/ws was interrupted while the page was loading

I have this error popping up every second. It started either after I ran "npm audit fix" or after I tried to install socket.io-client. Interestingly, this only happens in Firefox. I don't have any socket code, this is clearly related to hot reload. After I build the project, it works normally without errors. I googled a lot but haven't found a way to solve this. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空心空情空意 2025-02-07 17:27:11

我有同样的问题。就我而言,这是由开发服务器代理引起的。
我的应用程序是在vue.config中使用webpack和devserver属性,以将API调用从Frontend重定向到我的Localhost后端。
升级到VUE 2.7后,Firefox开始用WS进行垃圾邮件垃圾邮件控制台。
当我查看靠背的控制台时,我看到了很多要求 /WS端点的请求。

解决方案是将配置从后端更改

devServer: {
  proxy: "http://127.0.0.1:3000",
  ...
}

proxy: {
    "/api": {
      target: 'http://localhost:3000',
      pathRewrite: { '^/api': '' },
    },
  }

未收到 /WS的请求,而Firefox停止抱怨失败。
我不知道为什么Chrome没有这个问题。

I had same problem. In my case it was caused by dev server proxy.
My application was using webpack and devServer property in vue.config to redirect api calls from frontend to my localhost backend.
After upgrade to vue 2.7 firefox started spamming console with ws interrputed.
When I look at the console of my backed I saw a lot of request to /ws endpoint.

The solution was to change configuration from

devServer: {
  proxy: "http://127.0.0.1:3000",
  ...
}

to

proxy: {
    "/api": {
      target: 'http://localhost:3000',
      pathRewrite: { '^/api': '' },
    },
  }

After that backend was not receiving request for /ws and firefox stopped complaining about failures.
I have no idea why chrome didn't have that issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文