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:
parent
fc86745006
commit
1f3ba2bff1
1 changed files with 14 additions and 1 deletions
|
|
@ -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: "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue