diff --git a/src/app/app.module.ts b/src/app/app.module.ts index ece0ffd47e..47c6467d23 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -43,11 +43,31 @@ export class AppModule { } private initializeApp() { - environment.BASE_URL = this.getCurrentDomain() + environment.API_WEB = environment.API_WEB.replace( + '', + this.getSubDomain() + ) + environment.BASE_URL = environment.BASE_URL.replace( + '', + this.getSubDomain() + ) + environment.API_WEB = environment.API_WEB.replace( + '', + this.getCurrentLeanDomain() + ) + environment.BASE_URL = environment.BASE_URL.replace( + '', + this.getCurrentLeanDomain() + ) } - getCurrentDomain() { + getCurrentLeanDomain() { const port = window.location.port ? ':' + window.location.port : '' - return '//' + window.location.hostname + port + '/' + return window.location.hostname.split('.').slice(-2).join('.') + port + } + + getSubDomain() { + const subdomain = window.location.hostname.split('.').slice(0, -2).join('.') + return subdomain ? subdomain + '.' : '' } } diff --git a/src/environments/environment.int.ts b/src/environments/environment.int.ts index b35ed5508d..649ef4d378 100644 --- a/src/environments/environment.int.ts +++ b/src/environments/environment.int.ts @@ -5,9 +5,9 @@ export const environment = { debugger: true, ROBOTS: 'noindex, nofollow', API_NEWS: 'https://info.int.orcid.org/feed/', - API_PUB: `//pub.${getSubDomain()}orcid.org/v3.0`, - API_WEB: `//${getSubDomain()}orcid.org/`, - BASE_URL: '', + API_PUB: `//pub./v3.0`, + API_WEB: `///`, + BASE_URL: '///', INFO_SITE: 'https://info.qa.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: true, GOOGLE_TAG_MANAGER: 'GTM-0000000', diff --git a/src/environments/environment.local-with-proxy.ts b/src/environments/environment.local-with-proxy.ts index c8064495dd..ffa66255b3 100644 --- a/src/environments/environment.local-with-proxy.ts +++ b/src/environments/environment.local-with-proxy.ts @@ -1,13 +1,11 @@ -import { getSubDomain } from './subdomain.adapter' - export const environment = { production: false, debugger: true, ROBOTS: 'all', API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', - API_PUB: `//${getSubDomain()}localhost:4200/v3.0`, - API_WEB: `//${getSubDomain()}localhost:4200/`, - BASE_URL: '', + API_PUB: `///v3.0`, + API_WEB: `///`, + BASE_URL: '///', INFO_SITE: 'https://info.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: true, GOOGLE_TAG_MANAGER: 'GTM-0000000', diff --git a/src/environments/environment.local.ts b/src/environments/environment.local.ts index d784c9e438..5941c79dcd 100644 --- a/src/environments/environment.local.ts +++ b/src/environments/environment.local.ts @@ -1,13 +1,11 @@ -import { getSubDomain } from './subdomain.adapter' - export const environment = { production: false, debugger: true, ROBOTS: 'all', API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', - API_PUB: `//pub.${getSubDomain()}orcid.org/v3.0`, - API_WEB: `//${getSubDomain()}orcid.org/`, - BASE_URL: '', + API_PUB: `//pub./v3.0`, + API_WEB: `///`, + BASE_URL: '///', INFO_SITE: 'https://info.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: true, GOOGLE_TAG_MANAGER: 'GTM-0000000', diff --git a/src/environments/environment.production.ts b/src/environments/environment.production.ts index 615db6efd0..09eae28d28 100644 --- a/src/environments/environment.production.ts +++ b/src/environments/environment.production.ts @@ -1,13 +1,11 @@ -import { getSubDomain } from './subdomain.adapter' - export const environment = { production: true, debugger: false, ROBOTS: 'all', API_NEWS: 'https://info.orcid.org/feed/', - API_PUB: `//pub.${getSubDomain()}orcid.org/v3.0`, - API_WEB: `//${getSubDomain()}orcid.org/`, - BASE_URL: '', + API_PUB: `//pub./v3.0`, + API_WEB: `///`, + BASE_URL: '///', INFO_SITE: 'https://info.orcid.org/', SHOW_TEST_WARNING_BANNER: false, GOOGLE_ANALYTICS_TESTING_MODE: false, diff --git a/src/environments/environment.qa.ts b/src/environments/environment.qa.ts index 415f9d3ece..e3e754aaca 100644 --- a/src/environments/environment.qa.ts +++ b/src/environments/environment.qa.ts @@ -1,13 +1,11 @@ -import { getSubDomain } from './subdomain.adapter' - export const environment = { production: true, debugger: true, ROBOTS: 'noindex, nofollow', API_NEWS: 'https://info.qa.orcid.org/feed/', - API_PUB: `//pub.${getSubDomain()}orcid.org/v3.0`, - API_WEB: `//${getSubDomain()}orcid.org/`, - BASE_URL: '', + API_PUB: `//pub./v3.0`, + API_WEB: `///`, + BASE_URL: '///', INFO_SITE: 'https://info.qa.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: true, GOOGLE_TAG_MANAGER: 'GTM-TRLHLRZ', diff --git a/src/environments/environment.sandbox.ts b/src/environments/environment.sandbox.ts index 687174355f..40106352b1 100644 --- a/src/environments/environment.sandbox.ts +++ b/src/environments/environment.sandbox.ts @@ -1,13 +1,11 @@ -import { getSubDomain } from './subdomain.adapter' - export const environment = { production: true, debugger: false, ROBOTS: 'noindex, nofollow', API_NEWS: 'https://info.qa.orcid.org/feed/', - API_PUB: `//pub.${getSubDomain()}orcid.org/v3.0`, - API_WEB: `//${getSubDomain()}orcid.org/`, - BASE_URL: '', + API_PUB: `//pub./v3.0`, + API_WEB: `///`, + BASE_URL: '///', INFO_SITE: 'https://info.qa.orcid.org/', GOOGLE_ANALYTICS_TESTING_MODE: false, GOOGLE_TAG_MANAGER: 'GTM-M9Z7DHS', diff --git a/src/environments/subdomain.adapter.ts b/src/environments/subdomain.adapter.ts deleted file mode 100644 index c0d3e60aee..0000000000 --- a/src/environments/subdomain.adapter.ts +++ /dev/null @@ -1,4 +0,0 @@ -export function getSubDomain() { - const subdomain = window.location.hostname.split('.').slice(0, -2).join('.') - return subdomain ? subdomain + '.' : '' -}