Allow origin to be overridden by query

Specifying overrideOrigin in the URL now
sets up the store with the modified origin.
This is intended for development, and makes it
much less annoying to develop with a Vue dev server.
This commit is contained in:
Richard Bowman 2021-02-23 15:54:28 +00:00
parent fc86745006
commit 1f3ba2bff1

View file

@ -3,9 +3,22 @@ import Vuex from "vuex";
Vue.use(Vuex);
function getOriginFromLocation(){
// This will default to the same origin that's serving
// the web app - but can be overridden by the URL.
// See also devTools.vue which can change the origin.
let url = new URL(window.location.href);
let origin = url.searchParams.get("overrideOrigin");
if(origin){
return origin;
}else{
return url.origin;
}
}
export default new Vuex.Store({
state: {
origin: window.location.origin,
origin: getOriginFromLocation(),
available: false,
waiting: false,
error: "",