From a71ceec88a1cddc687e0db0d81e0424c84f37d12 Mon Sep 17 00:00:00 2001 From: Olivier Vernin Date: Mon, 3 Jul 2023 21:44:31 +0200 Subject: [PATCH] Allow to have runtime configuration Signed-off-by: Olivier Vernin --- .gitignore | 2 +- README.md | 17 +++++++++++++++++ package.json | 3 +++ public/index.html | 2 ++ src/main.js | 7 +++---- src/views/QuickStart.vue | 7 +++---- 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 2e63f6e1c..2539531f4 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ pnpm-debug.log* *.sln *.sw? -auth_config.json +public/config.js diff --git a/README.md b/README.md index 0628f7b39..7b90b21eb 100644 --- a/README.md +++ b/README.md @@ -20,5 +20,22 @@ npm run build npm run lint ``` +## Deploy to production + +For being able to have runtime configuration, we rely on the file `/usr/share/nginx/html/config.js` with the following content: + +``` +const config = (() => { + return { + "OAUTH_DOMAIN": "oauth domain", + "OAUTH_CLIENTID": "xxx", + "OAUTH_AUDIENCE": "http://localhost:8080/api" + }; +})(); +``` + +For the local development environment, this file must be located in `public/config.js`. +It shouldn't be commit to the git repository + ### Customize configuration See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/package.json b/package.json index 259e8c9e3..b2e6e1e1f 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,9 @@ "env": { "node": true }, + "globals": { + "config": "readonly" + }, "extends": [ "plugin:vue/vue3-essential", "eslint:recommended" diff --git a/public/index.html b/public/index.html index 412352865..97077a205 100644 --- a/public/index.html +++ b/public/index.html @@ -6,6 +6,8 @@ <%= htmlWebpackPlugin.options.title %> + +