diff --git a/index.html b/index.html index 015e4d3..9218d4e 100644 --- a/index.html +++ b/index.html @@ -17,6 +17,7 @@ + diff --git a/public/env-config.template.js b/public/env-config.template.js new file mode 100644 index 0000000..c40f2e8 --- /dev/null +++ b/public/env-config.template.js @@ -0,0 +1,7 @@ +window.__ENV__ = { + URL_KEYCLOAK: "${URL_KEYCLOAK}", + KEYCLOAK_REALM: "${KEYCLOAK_REALM}", + KEYCLOAK_CLIENT_ID: "${KEYCLOAK_CLIENT_ID}", + URL_FRONTEND: "${URL_FRONTEND}", + URL_BACKEND: "${URL_BACKEND}" +}; \ No newline at end of file diff --git a/src/boot/axios.ts b/src/boot/axios.ts index b3a0460..1589a9a 100644 --- a/src/boot/axios.ts +++ b/src/boot/axios.ts @@ -14,7 +14,7 @@ declare module '@vue/runtime-core' { // good idea to move this instance creation inside of the // "export default () => {}" function below (which runs individually // for each client) -const api = axios.create({ baseURL: process.env.URL_BACKEND }); +const api = axios.create({ baseURL: window.__ENV__?.URL_BACKEND }); export default boot(({ app }) => { // for use inside Vue files (Options API) through this.$axios and this.$api diff --git a/src/stores/user-store.ts b/src/stores/user-store.ts index 23ebc33..d35e3b7 100644 --- a/src/stores/user-store.ts +++ b/src/stores/user-store.ts @@ -10,10 +10,10 @@ import Keycloak, { KeycloakInitOptions, KeycloakLoginOptions } from 'keycloak-js * @param realm Name des Realms, hinterlegt in realm-export.json von Keycloak * @param clientId Name des Clients, hinterlegt in realm-export.json von Keycloak */ -const urlKeycloak: string = "" + process.env.URL_KEYCLOAK; -const urlFrontend: string = "" + process.env.URL_FRONTEND; -const realm : string= "" + process.env.KEYCLOAK_REALM; -const clientId: string = "" + process.env.KEYCLOAK_CLIENT_ID; +const urlKeycloak: string = "" + window.__ENV__?.URL_KEYCLOAK; +const urlFrontend: string = "" + window.__ENV__?.URL_FRONTEND; +const realm : string= "" + window.__ENV__?.KEYCLOAK_REALM; +const clientId: string = "" + window.__ENV__?.KEYCLOAK_CLIENT_ID; const keycloak: Keycloak = new Keycloak({ url: urlKeycloak, realm: realm,