mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 01:32:06 +10:00
fix: wip
This commit is contained in:
18
packages/lib/utils/env.ts
Normal file
18
packages/lib/utils/env.ts
Normal 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];
|
||||
};
|
||||
Reference in New Issue
Block a user