2
0

🚸 Skip validation if __ENV.js file does not exist

This commit is contained in:
Baptiste Arnaud
2023-08-31 09:57:54 +02:00
parent 9d29a88ed3
commit dfcfdf2138
9 changed files with 61 additions and 99 deletions

View File

@@ -2,10 +2,9 @@ declare const window: {
__ENV?: any
}
const isBrowser = () => Boolean(typeof window !== 'undefined' && window.__ENV)
export const getRuntimeVariable = (key: string) => {
if (isBrowser()) return window.__ENV[key]
if (typeof window !== 'undefined')
return window.__ENV ? window.__ENV[key] : undefined
if (typeof process === 'undefined') return undefined
return process.env[key]
}