Browse Source
Merge pull request #81 from Saibamen/use_NODE_ENV
Use `NODE_ENV` from Express and Socket.IO
pull/89/head
Louis Lam
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
7 additions and
2 deletions
-
src/mixins/socket.js
|
|
@ -35,7 +35,8 @@ export default { |
|
|
|
window.addEventListener('resize', this.onResize); |
|
|
|
|
|
|
|
let wsHost; |
|
|
|
if (localStorage.dev === "dev") { |
|
|
|
const env = process.env.NODE_ENV || 'development'; |
|
|
|
if (env === "development") { |
|
|
|
wsHost = ":3001" |
|
|
|
} else { |
|
|
|
wsHost = "" |
|
|
@ -45,6 +46,10 @@ export default { |
|
|
|
transports: ['websocket'] |
|
|
|
}); |
|
|
|
|
|
|
|
socket.on("connect_error", (err) => { |
|
|
|
console.error(`Failed to connect to the backend. Socket.io connect_error: ${err.message}`); |
|
|
|
}); |
|
|
|
|
|
|
|
socket.on('info', (info) => { |
|
|
|
this.info = info; |
|
|
|
}); |
|
|
@ -158,7 +163,7 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
getSocket() { |
|
|
|
return socket; |
|
|
|
return socket; |
|
|
|
}, |
|
|
|
|
|
|
|
toastRes(res) { |
|
|
|