forked from breatheco-de/app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodifyEnv.js
25 lines (20 loc) · 862 Bytes
/
modifyEnv.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { isWindow } from './src/utils';
const handleEnv = ({ queryString, env }) => {
let modifiedEnv = env;
if (isWindow) {
const urlHost = new URLSearchParams(window.location.search).get(queryString);
if (process.env.VERCEL_ENV !== 'production') {
if (urlHost && urlHost[urlHost.length - 1] === '/') urlHost.slice(0, -1);
if (urlHost) localStorage.setItem(queryString, urlHost);
if (localStorage.getItem(queryString)) modifiedEnv = localStorage.getItem(queryString);
if (modifiedEnv === 'reset') modifiedEnv = env;
if (modifiedEnv === 'production') modifiedEnv = 'https://breathecode.herokuapp.com';
}
}
return modifiedEnv;
};
const modifyEnv = ({ queryString = 'host', env = process.env.BREATHECODE_HOST }) => {
const host = handleEnv({ queryString, env });
return host;
};
export default modifyEnv;