Skip to content

Commit

Permalink
DIGG-496: Updating check for sandbox environment
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaMunterud committed Dec 6, 2024
1 parent d8cde92 commit d2b005a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ REACT_APP_SCREEN9_API_TOKEN=secret
# IMAGE_DOMAIN=dev.beta.graphql.dataportal.dev1.se
# REACT_APP_MEDIA_BASE_URL=https://dev.beta.strapi.dataportal.dev1.se

## Connect to production backend (beta.dataportal.se).
## Connect to production backend (dataportal.se).
APOLLO_URL=https://graphql.digg.se/
REACT_APP_APOLLO_URL=https://graphql.digg.se/
IMAGE_DOMAIN=graphql.digg.se
Expand Down
14 changes: 9 additions & 5 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function Dataportal({ Component, pageProps }: DataportalenProps) {
const { asPath } = useRouter();
const { t, lang } = useTranslation();
// Put shared props into state to persist between pages that doesn't use getStaticProps
const [env, setEnv] = useState<EnvSettings>(SettingsUtil.create());
const [env, setEnv] = useState<EnvSettings | null>(null);
const [settingsOpen, setSettingsOpen] = useState(false);
const [matomoActivated, setMatomoActivated] = useState<boolean>(true);
const [openSideBar, setOpenSideBar] = useState(false);
Expand All @@ -94,13 +94,13 @@ function Dataportal({ Component, pageProps }: DataportalenProps) {

useEffect(() => {
if (typeof window !== "undefined") {
const clienthost = window?.location?.host || "";

const isSandbox = window.location.host.includes("sandbox");
//if host is run from sandbox, load that environment and disable matomo
if (clienthost?.includes("sandbox")) {
if (isSandbox) {
setEnv(new Settings_Sandbox());
//disable matomo
setMatomoActivated(false);
} else {
setEnv(SettingsUtil.create());
}
}
document.documentElement.classList.add("no-focus-outline");
Expand Down Expand Up @@ -132,6 +132,10 @@ function Dataportal({ Component, pageProps }: DataportalenProps) {
setImageHero(heroImage);
}, [pathname]);

if (!env) {
return null;
}

return (
<ApolloProvider client={client}>
<SettingsProvider
Expand Down

0 comments on commit d2b005a

Please sign in to comment.