diff --git a/.env.example b/.env.example index d65dc10..89954a0 100644 --- a/.env.example +++ b/.env.example @@ -2,4 +2,5 @@ PROD_URL = "https://api.example.com" DEV_URL = "https://api.example.com" APP_URL = "https://app.example.com" DEV_HOST = 0.0.0.0 -DEV_PORT = 80 \ No newline at end of file +DEV_PORT = 80 +DOCKER_BUILD = false \ No newline at end of file diff --git a/quasar.conf.js b/quasar.conf.js index 59446d3..4ba32c4 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -29,7 +29,7 @@ module.exports = function () { // Full list of options: https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-build build: { - env: { DEV_API: process.env.DEV_URL, PROD_API: process.env.PROD_URL }, + env: { DEV_API: process.env.DEV_URL, PROD_API: process.env.PROD_URL, DOCKER_BUILD: process.env.DOCKER_BUILD }, vueRouterMode: 'history', // available values: 'hash', 'history' distDir: "dist/", diff --git a/src/boot/axios.js b/src/boot/axios.js index 5a53a57..bd76f10 100644 --- a/src/boot/axios.js +++ b/src/boot/axios.js @@ -5,9 +5,16 @@ export default function ({ router, store }) { Vue.prototype.$axios = axios; - axios.defaults.baseURL = process.env.NODE_ENV === "production" - ? process.env.PROD_API || window._env_.PROD_URL - : process.env.DEV_API; + axios.defaults.baseURL = () => { + if (process.env.NODE_ENV === "production") { + if (process.env.DOCKER_BUILD) { + return window._env_.PROD_URL + } + return process.env.PROD_API + } else { + return process.env.DEV_API; + } + } axios.interceptors.request.use( function (config) {