Move the prod and dev websocket URI to a config file.
This commit is contained in:
parent
3359c84fe4
commit
50b3efec4c
2 changed files with 15 additions and 7 deletions
11
web/src/config.js
Normal file
11
web/src/config.js
Normal 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;
|
||||||
|
|
@ -4,17 +4,14 @@ import store from './store';
|
||||||
import io from 'socket.io-client';
|
import io from 'socket.io-client';
|
||||||
import clipboard from "vue-clipboard2";
|
import clipboard from "vue-clipboard2";
|
||||||
import VueSocketIOExt from 'vue-socket.io-extended';
|
import VueSocketIOExt from 'vue-socket.io-extended';
|
||||||
|
import {websocket_uri, dev_websocket_uri} from "./config";
|
||||||
|
|
||||||
Vue.config.productionTip = false;
|
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(clipboard);
|
||||||
Vue.use(VueSocketIOExt, io(websocket_uri));
|
Vue.use(VueSocketIOExt, io(
|
||||||
|
process.env.NODE_ENV === `development` ? websocket_uri : dev_websocket_uri
|
||||||
|
));
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
store,
|
store,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue