fix(web): getDefaultApiUrl should handle stage.roleypoly.com as stage

This commit is contained in:
41666 2021-03-13 04:55:20 -05:00
parent cd448b56c9
commit a87ccd9c54
2 changed files with 6 additions and 2 deletions

View file

@ -2,6 +2,7 @@ import { getDefaultApiUrl } from './getDefaultApiUrl';
it.each([
['https://next.roleypoly.com/servers', 'https://api-prod.roleypoly.com'],
['https://stage.roleypoly.com/servers', 'https://api-stage.roleypoly.com'],
['https://roleypoly.com/servers', 'https://api-prod.roleypoly.com'],
['https://notroleypolybutclose.com/servers', 'https://api-prod.roleypoly.com'],
['https://myhash.roleypoly.pages.dev/servers', 'https://api-stage.roleypoly.com'],

View file

@ -1,7 +1,10 @@
export const getDefaultApiUrl = (host: string = window.location.hostname) => {
if (/roleypoly.com$/.test(host)) {
if (/^roleypoly.com$/.test(host)) {
return 'https://api-prod.roleypoly.com';
} else if (/roleypoly\.pages\.dev$/.test(host)) {
} 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';