Skip to content

Commit

Permalink
Merge pull request #1995 from ever-co/fix/envs-loading
Browse files Browse the repository at this point in the history
Improve Env Retrieval
  • Loading branch information
evereq authored Dec 13, 2023
2 parents 802c495 + a27b5a3 commit 6e89bf9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions apps/web/app/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,10 @@ export function setNextPublicEnv(envs: Env) {
export function loadNextPublicEnvs() {
return Object.keys(process.env)
.filter((key) => key.startsWith('NEXT_PUBLIC'))
.reduce(
(acc, value) => {
if (process.env[value]) {
acc[value] = process.env[value] as string;
}
return acc;
},
{} as Record<string, string>
);
.reduce((acc, value) => {
acc[value] = process.env[value];
return acc;
}, {} as Env);
}

// Preload Some variables
Expand Down
2 changes: 1 addition & 1 deletion apps/web/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ MyApp.getInitialProps = async ({ Component, ctx }: { Component: NextPage<AppProp
jitsuHost,
jitsuWriteKey,
envs: loadNextPublicEnvs()
}
} as MyAppProps
};
};

Expand Down

0 comments on commit 6e89bf9

Please sign in to comment.