From bca1e73a033f0ba950505087ad36baf0250f98e8 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Wed, 14 Jun 2023 10:25:39 +0300 Subject: [PATCH] Better env --- src/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index f7a0d4a9..3375c7d3 100644 --- a/src/index.js +++ b/src/index.js @@ -23,15 +23,15 @@ import installSearchEngine from './search'; import GeocharsWidget from './components/theme/Widgets/GeocharsWidget'; import GeolocationWidget from './components/theme/Widgets/GeolocationWidget'; +const getEnv = () => (typeof window !== 'undefined' ? window.env : process.env); + const applyConfig = (config) => { const notInEnMission = /^(?!(\/en\/mission)).*$/; - if ( - !( - __DEVELOPMENT__ || - (process.env.RAZZLE_DISABLE_EXTERNAL_ROUTES && - process.env.RAZZLE_DISABLE_EXTERNAL_ROUTES === 'True') - ) - ) { + const env = getEnv(); + const isStaging = !!env.RAZZLE_IS_STAGING; + const enableMissionIsExternal = !isStaging && !__DEVELOPMENT__; + + if (enableMissionIsExternal) { config.settings.externalRoutes = [ ...(config.settings.externalRoutes || []), {