From c5b88b66aa92e18a7b7cb85bf6b56f329da5f784 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Wed, 23 Oct 2024 00:07:45 +0200 Subject: [PATCH] feat(Header): show local or staging suffix if not in prod. ref #876 --- .env.local | 1 + .env.preprod | 1 + .env.prod | 1 + src/components/Header.vue | 2 ++ src/constants.js | 10 +++++----- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.env.local b/.env.local index b14a6286a8..dbe9105638 100644 --- a/.env.local +++ b/.env.local @@ -1,3 +1,4 @@ +VITE_OPEN_PRICES_ENV = "local" VITE_OPEN_PRICES_APP_URL = "http://127.0.0.1:8000" VITE_OPEN_PRICES_API_URL = "http://127.0.0.1:8000/api/v1" VITE_MANIFEST_PATH = "/manifest.local.json" diff --git a/.env.preprod b/.env.preprod index e4a55060ae..1b553c7601 100644 --- a/.env.preprod +++ b/.env.preprod @@ -1,3 +1,4 @@ +VITE_OPEN_PRICES_ENV = "staging" VITE_OPEN_PRICES_APP_URL = "https://prices.openfoodfacts.net" VITE_OPEN_PRICES_API_URL = "https://prices.openfoodfacts.net/api/v1" VITE_MANIFEST_PATH = "/manifest.preprod.json" diff --git a/.env.prod b/.env.prod index 883efe7961..1791d18fe5 100644 --- a/.env.prod +++ b/.env.prod @@ -1,3 +1,4 @@ +VITE_OPEN_PRICES_ENV = "prod" VITE_OPEN_PRICES_APP_URL = "https://prices.openfoodfacts.org" VITE_OPEN_PRICES_API_URL = "https://prices.openfoodfacts.org/api/v1" VITE_MANIFEST_PATH = "/manifest.prod.json" diff --git a/src/components/Header.vue b/src/components/Header.vue index 9f6b742caf..7ddcb62683 100644 --- a/src/components/Header.vue +++ b/src/components/Header.vue @@ -5,6 +5,7 @@ {{ APP_NAME }} + {{ ENV }} @@ -62,6 +63,7 @@ export default { data() { return { APP_NAME: constants.APP_NAME, + ENV: import.meta.env.VITE_OPEN_PRICES_ENV, showDrawerMenu: false, showProfileMenu: false, } diff --git a/src/constants.js b/src/constants.js index 570fcce4b0..1c08a6fed9 100644 --- a/src/constants.js +++ b/src/constants.js @@ -17,12 +17,12 @@ const LOCATION_TYPE_ONLINE_ICON = 'mdi-web' export default { APP_NAME: 'Open Prices', - APP_URL: 'https://prices.openfoodfacts.org', - APP_API_URL: 'https://prices.openfoodfacts.org/api/docs', + APP_URL: import.meta.env.VITE_OPEN_PRICES_APP_URL, + APP_API_URL: `${import.meta.env.VITE_OPEN_PRICES_APP_URL}/api/docs`, APP_USER_AGENT: 'Open Prices Web App', - APP_DUMP_PRICES_URL: 'https://prices.openfoodfacts.org/data/prices.jsonl.gz', - APP_DUMP_PROOFS_URL: 'https://prices.openfoodfacts.org/data/proofs.jsonl.gz', - APP_DUMP_LOCATIONS_URL: 'https://prices.openfoodfacts.org/data/locations.jsonl.gz', + APP_DUMP_PRICES_URL: `${import.meta.env.VITE_OPEN_PRICES_APP_URL}/data/prices.jsonl.gz`, + APP_DUMP_PROOFS_URL: `${import.meta.env.VITE_OPEN_PRICES_APP_URL}/data/proofs.jsonl.gz`, + APP_DUMP_LOCATIONS_URL: `${import.meta.env.VITE_OPEN_PRICES_APP_URL}/data/locations.jsonl.gz`, APP_GITHUB_FRONTEND_URL: 'https://github.com/openfoodfacts/open-prices-frontend', OFF_NAME: OFF_NAME, OFF_URL: 'https://world.openfoodfacts.org',