From 08f14623fc91b4f7fd70d59c2b061bc9fc46bfb1 Mon Sep 17 00:00:00 2001 From: Stefan Peters Date: Tue, 19 Nov 2024 09:06:15 +0100 Subject: [PATCH] Adjust login config variable and how env configuration is loaded --- README.md | 8 +++++++- src/config.js | 3 +-- vite.config.js | 7 ------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 07fbb7a..8698eb6 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,15 @@ There is an input form to give a PPN from K10plus catalogue. - *Writing selected enrichment back to K10plus has not been implemented yet* ## Configuration -Currently not applicable, but will be relevant when a server component is added. +Configuration can be adjusted via a `.env` file. Variables prefixed with `VITE_` can be used in the client as well. +```env +# Base path on which your app will be hosted +BASE=/ +# Login Server instance base URL +VITE_LOGIN_SERVER=http://localhost:3004 +``` ## To-Dos - [ ] Code cleanup diff --git a/src/config.js b/src/config.js index 2573e54..22e5092 100644 --- a/src/config.js +++ b/src/config.js @@ -34,7 +34,6 @@ export const concordanceRegistry = cdk.initializeRegistry({ api: concordanceApi, }) -// eslint-disable-next-line no-undef -const loginServer = LOGIN_SERVER || null +const loginServer = import.meta.env.VITE_LOGIN_SERVER || null export const loginServerUrl = loginServer && loginServer.replace(/https?:\/\//, "") export const loginServerSsl = loginServer && loginServer.startsWith("https://") diff --git a/vite.config.js b/vite.config.js index 17df72b..893a12f 100644 --- a/vite.config.js +++ b/vite.config.js @@ -2,19 +2,12 @@ import { defineConfig } from "vite" import vue from "@vitejs/plugin-vue" import { fileURLToPath } from "url" -import dotenv from "dotenv" -dotenv.config() - const base = process.env.BASE || "/" const isProduction = process.env.NODE_ENV === "production" // https://vitejs.dev/config/ export default defineConfig({ plugins: [vue()], - define: { - BASE: `"${base || ""}"`, - LOGIN_SERVER: `"${process.env.LOGIN || ""}"`, - }, resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)),