0
0
Fork 0

Move the prod and dev websocket URI to a config file.

This commit is contained in:
Oliver-Akins 2021-03-03 22:22:14 -07:00
parent 3359c84fe4
commit 50b3efec4c
2 changed files with 15 additions and 7 deletions

11
web/src/config.js Normal file
View file

@ -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;

View file

@ -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,