本文介绍了将 WebSocket 连接航行到 'ws:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过命令在生产中运行服务器风帆:sails lift --prod 然后我有错误:

I try to run server sails in production via command: sails lift --prod then I have error:

VM448 production.min.js:1 WebSocket 连接到 'ws://localhost:1337/socket.io/?__sails_io_sdk_version=1.2.1&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIOport=websocket' 失败:WebSocket 握手期间出错:意外响应代码:400

当我通过以下方式在开发环境中运行服务器时:sails lift 效果很好.我该如何解决这个问题?

When I run server in development environment via: sails lift that works well.How can I fix this problem?

推荐答案

为了解决这个问题,我在位于 config/env/production.js 的 production.js 中添加了站点链接.我在位于 sokets 的 onlyAllowOrigins 中添加了链接.

For fix this problem I added links of site in production.js that locates in config/env/production.js.I added links in onlyAllowOrigins that locates in sokets.

  onlyAllowOrigins: [
  'http://example.com',
  'https://myPage.com',
  'http://localhost:1337'
  // 'https://staging.example.com',
],

这篇关于将 WebSocket 连接航行到 'ws:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 18:45