问题
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