Sails WebSocket connection to 'ws:

て烟熏妆下的殇ゞ 提交于 2021-01-28 19:14:39

问题


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

VM448 production.min.js:1 WebSocket connection to 'ws://localhost:1337/socket.io/?__sails_io_sdk_version=1.2.1&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 400

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


回答1:


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',
],


来源:https://stackoverflow.com/questions/50739208/sails-websocket-connection-to-ws

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!