diff --git a/frontend/quasar.conf.js b/frontend/quasar.conf.js index b557976..f95dbf8 100644 --- a/frontend/quasar.conf.js +++ b/frontend/quasar.conf.js @@ -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: { diff --git a/frontend/src/boot/axios.js b/frontend/src/boot/axios.js index 7ada677..8523d48 100644 --- a/frontend/src/boot/axios.js +++ b/frontend/src/boot/axios.js @@ -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 } diff --git a/frontend/src/pages/Overview.vue b/frontend/src/pages/Overview.vue index bb66a29..0831ffa 100644 --- a/frontend/src/pages/Overview.vue +++ b/frontend/src/pages/Overview.vue @@ -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() })