diff --git a/web/src/config.js b/web/src/config.js new file mode 100644 index 0000000..a887287 --- /dev/null +++ b/web/src/config.js @@ -0,0 +1,11 @@ +/** + * The URI that socket IO tries to connect to for websocket communication when + * built for production serving. + */ +export const websocket_uri = `/`; + +/** + * The websocket URI that Socket.IO tries to connect to when live-serving the + * site via webpack. + */ +export const dev_websocket_uri = 8081; \ No newline at end of file diff --git a/web/src/main.js b/web/src/main.js index 2f38b4d..40854df 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -4,17 +4,14 @@ import store from './store'; import io from 'socket.io-client'; import clipboard from "vue-clipboard2"; import VueSocketIOExt from 'vue-socket.io-extended'; +import {websocket_uri, dev_websocket_uri} from "./config"; Vue.config.productionTip = false; -// Get the URI for dev enfironments -let websocket_uri = `/`; -if (process.env.NODE_ENV === `development`) { - websocket_uri = `http://${window.location.hostname}:8081`; -}; - Vue.use(clipboard); -Vue.use(VueSocketIOExt, io(websocket_uri)); +Vue.use(VueSocketIOExt, io( + process.env.NODE_ENV === `development` ? websocket_uri : dev_websocket_uri +)); new Vue({ store,