centralized API-URL in quasar.conf.js

This commit is contained in:
Timo Volkmann 2019-04-15 18:00:32 +02:00
parent 8ee93cd9c0
commit 789c04a8e8
3 changed files with 21 additions and 4 deletions

View File

@ -100,7 +100,15 @@ module.exports = function (ctx) {
loader: 'eslint-loader',
exclude: /node_modules/
})
}
},
env: ctx.dev
? { // Base URL for API-Calls: DEV
API: JSON.stringify('http://localhost:8080')
}
: { // Base URL for API-Calls: PRODUCTION (build)
API: JSON.stringify('http://se.hs-heilbronn.de:8090')
//API: JSON.stringify('http://se.hs-heilbronn.de:8090')
}
},
devServer: {

View File

@ -1,5 +1,14 @@
import axios from "axios";
const axiosInstance = axios.create({
baseURL: process.env.API
});
console.log("process.env.DEV: "+process.env.DEV);
console.log("process.env.API: "+process.env.API);
export default async ({ Vue }) => {
Vue.prototype.$axios = axios;
//Vue.prototype.$axios = axios;
Vue.prototype.$axios = axiosInstance;
};
export { axiosInstance }

View File

@ -113,7 +113,7 @@
},
methods: {
fetchAllCaches() {
this.$axios.get('http://localhost:8080/api/allCaches')
this.$axios.get('/api/allCaches')
.then((response) => {
console.log("Caches: " + this.caches);
this.caches = response.data;
@ -126,7 +126,7 @@
},
deleteCache(id) {
console.log('delete cache: ' + id)
this.$axios.delete('http://localhost:8080/api/deleteCache', {params: {cacheID: id}})
this.$axios.delete('/api/deleteCache', {params: {cacheID: id}})
.then((response) => {
this.fetchAllCaches()
})