fix(web): api context should pass it's current hostname into API URL selector

This commit is contained in:
41666 2021-03-13 05:21:09 -05:00
parent eb2537ae35
commit 2b467b8452
2 changed files with 17 additions and 17 deletions

View file

@ -1,18 +1,16 @@
import * as memoizeOne from 'memoize-one';
export const getDefaultApiUrl = memoizeOne.default(
(host: string = window.location.hostname) => {
if (/^roleypoly.com$/.test(host)) {
return 'https://api-prod.roleypoly.com';
} else if (
/roleypoly\.pages\.dev$/.test(host) ||
/^stage.roleypoly.com$/.test(host)
) {
return 'https://api-stage.roleypoly.com';
} else if (/\blocalhost|127\.0\.0\.1\b/.test(host)) {
return 'http://localhost:6609';
} else {
return 'https://api-prod.roleypoly.com';
}
export const getDefaultApiUrl = memoizeOne.default((host: string) => {
if (/^roleypoly.com$/.test(host)) {
return 'https://api-prod.roleypoly.com';
} else if (
/roleypoly\.pages\.dev$/.test(host) ||
/^stage.roleypoly.com$/.test(host)
) {
return 'https://api-stage.roleypoly.com';
} else if (/\blocalhost|127\.0\.0\.1\b/.test(host)) {
return 'http://localhost:6609';
} else {
return 'https://api-prod.roleypoly.com';
}
);
});