This commit is contained in:
David Nguyen
2025-01-31 14:09:02 +11:00
parent f7a98180d7
commit d7d0fca501
146 changed files with 1250 additions and 1263 deletions

18
packages/lib/utils/env.ts Normal file
View File

@ -0,0 +1,18 @@
/// <reference types="@documenso/tsconfig/process-env.d.ts" />
type EnvironmentVariable = keyof NodeJS.ProcessEnv;
export const env = (variable: EnvironmentVariable | (string & {})) => {
// console.log({
// ['typeof window']: typeof window,
// ['process.env']: process.env,
// ['window.__ENV__']: typeof window !== 'undefined' && window.__ENV__,
// });
// This may need ot be import.meta.env.SSR depending on vite.
if (typeof window !== 'undefined' && typeof window.__ENV__ === 'object') {
return window.__ENV__[variable];
}
return process.env[variable];
};