From f755ec8c0b7bf01ebae01a8a584bdbc9770bdc6d Mon Sep 17 00:00:00 2001
From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de>
Date: Fri, 16 Feb 2018 14:10:04 +0100
Subject: [PATCH] axios base url and vuex strict mode dependant on NODE_ENV

---
 frontend/src/api.js         | 10 +++++++++-
 frontend/src/store/store.js |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/frontend/src/api.js b/frontend/src/api.js
index 44842d4c..007ebc14 100644
--- a/frontend/src/api.js
+++ b/frontend/src/api.js
@@ -6,8 +6,16 @@ function addFieldsToUrl ({url, fields = []}) {
   return fields.length > 0 ? url + '?fields=pk,' + fields : url
 }
 
+function getInstanceBaseUrl () {
+  if (process.env.NODE_ENV === 'production') {
+    return `https://${window.location.host}${window.location.pathname}`
+  } else {
+    return 'http://localhost:8000/'
+  }
+}
+
 let ax = axios.create({
-  baseURL: 'http://localhost:8000/',
+  baseURL: getInstanceBaseUrl(),
   headers: {'Authorization': 'JWT ' + sessionStorage.getItem('token')}
 })
 
diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js
index c48d87c0..09af4790 100644
--- a/frontend/src/store/store.js
+++ b/frontend/src/store/store.js
@@ -30,7 +30,7 @@ export const persistedStateKey = 'grady'
 
 const store = new Vuex.Store({
   // TODO only enable this in dev and not in deployment (use env variable)
-  strict: true,
+  strict: process.env.NODE_ENV === 'development',
   modules: {
     authentication,
     studentPage,
-- 
GitLab