Skip to content

Commit

Permalink
Calculate url on runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
leomendoza123 committed Oct 24, 2023
1 parent aeae131 commit 731dd49
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 26 deletions.
9 changes: 9 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,19 @@ export class AppModule {

private initializeApp() {
environment.BASE_URL = this.getCurrentDomain()
environment.API_WEB = environment.API_WEB.replace(
'<SUBDOMAIN>',
this.getSubDomain()
)
}

getCurrentDomain() {
const port = window.location.port ? ':' + window.location.port : ''
return '//' + window.location.hostname + port + '/'
}

getSubDomain() {
const subdomain = window.location.hostname.split('.').slice(0, -2).join('.')
return subdomain ? subdomain + '.' : ''
}
}
4 changes: 2 additions & 2 deletions src/environments/environment.int.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ 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/`,
API_PUB: `//pub.<SUBDOMAIN>orcid.org/v3.0`,
API_WEB: `//<SUBDOMAIN>orcid.org/`,
BASE_URL: '',
INFO_SITE: 'https://info.qa.orcid.org/',
GOOGLE_ANALYTICS_TESTING_MODE: true,
Expand Down
6 changes: 2 additions & 4 deletions src/environments/environment.local-with-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
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/`,
API_PUB: `//<SUBDOMAIN>localhost:4200/v3.0`,
API_WEB: `//<SUBDOMAIN>localhost:4200/`,
BASE_URL: '',
INFO_SITE: 'https://info.orcid.org/',
GOOGLE_ANALYTICS_TESTING_MODE: true,
Expand Down
6 changes: 2 additions & 4 deletions src/environments/environment.local.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
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/`,
API_PUB: `//pub.<SUBDOMAIN>orcid.org/v3.0`,
API_WEB: `//<SUBDOMAIN>orcid.org/`,
BASE_URL: '',
INFO_SITE: 'https://info.orcid.org/',
GOOGLE_ANALYTICS_TESTING_MODE: true,
Expand Down
6 changes: 2 additions & 4 deletions src/environments/environment.production.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
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/`,
API_PUB: `//pub.<SUBDOMAIN>orcid.org/v3.0`,
API_WEB: `//<SUBDOMAIN>orcid.org/`,
BASE_URL: '',
INFO_SITE: 'https://info.orcid.org/',
SHOW_TEST_WARNING_BANNER: false,
Expand Down
6 changes: 2 additions & 4 deletions src/environments/environment.qa.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
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/`,
API_PUB: `//pub.<SUBDOMAIN>orcid.org/v3.0`,
API_WEB: `//<SUBDOMAIN>orcid.org/`,
BASE_URL: '',
INFO_SITE: 'https://info.qa.orcid.org/',
GOOGLE_ANALYTICS_TESTING_MODE: true,
Expand Down
6 changes: 2 additions & 4 deletions src/environments/environment.sandbox.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
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/`,
API_PUB: `//pub.<SUBDOMAIN>orcid.org/v3.0`,
API_WEB: `//<SUBDOMAIN>orcid.org/`,
BASE_URL: '',
INFO_SITE: 'https://info.qa.orcid.org/',
GOOGLE_ANALYTICS_TESTING_MODE: false,
Expand Down
4 changes: 0 additions & 4 deletions src/environments/subdomain.adapter.ts

This file was deleted.

0 comments on commit 731dd49

Please sign in to comment.