chore: Use web app url instead of cors protocol, port and host

This commit is contained in:
Faruk AYDIN
2021-11-23 11:16:57 +01:00
committed by Ali BARIN
parent f8e823545a
commit 77ab83b43b
2 changed files with 3 additions and 10 deletions

View File

@@ -1,8 +1,7 @@
HOST=localhost HOST=localhost
PROTOCOL=http PROTOCOL=http
PORT=3000 PORT=3000
CORS_PORT=3001 WEB_APP_URL=https://localhost:3001
CORS_PROTOCOL=https
APP_ENV=development APP_ENV=development
POSTGRES_DATABASE=automatisch_development POSTGRES_DATABASE=automatisch_development
POSTGRES_PORT=5432 POSTGRES_PORT=5432

View File

@@ -5,8 +5,7 @@ type AppConfig = {
host: string, host: string,
protocol: string protocol: string
port: string, port: string,
corsPort: string, webAppUrl: string,
corsProtocol: string,
appEnv: string, appEnv: string,
postgresDatabase: string, postgresDatabase: string,
postgresPort: number, postgresPort: number,
@@ -14,15 +13,13 @@ type AppConfig = {
postgresUsername: string, postgresUsername: string,
postgresPassword: string, postgresPassword: string,
baseUrl?: string baseUrl?: string
webAppUrl?: string
} }
const appConfig: AppConfig = { const appConfig: AppConfig = {
host: process.env.HOST || 'localhost', host: process.env.HOST || 'localhost',
protocol: process.env.PROTOCOL || 'http', protocol: process.env.PROTOCOL || 'http',
port: process.env.PORT || '3000', port: process.env.PORT || '3000',
corsPort: process.env.CORS_PORT || '3001', webAppUrl: process.env.webAppUrl || 'https://localhost:3001',
corsProtocol: process.env.CORS_PROTOCOL || 'http',
appEnv: process.env.APP_ENV || 'development', appEnv: process.env.APP_ENV || 'development',
postgresDatabase: process.env.POSTGRES_DATABASE || 'automatisch_development', postgresDatabase: process.env.POSTGRES_DATABASE || 'automatisch_development',
postgresPort: parseInt(process.env.POSTGRES_PORT) || 5432, postgresPort: parseInt(process.env.POSTGRES_PORT) || 5432,
@@ -31,9 +28,6 @@ const appConfig: AppConfig = {
postgresPassword: process.env.POSTGRESS_PASSWORD, postgresPassword: process.env.POSTGRESS_PASSWORD,
} }
const webAppUrl = `${appConfig.corsProtocol}://${appConfig.host}:${appConfig.corsPort}`;
appConfig.webAppUrl = webAppUrl;
const baseUrl = `${appConfig.protocol}://${appConfig.host}:${appConfig.port}`; const baseUrl = `${appConfig.protocol}://${appConfig.host}:${appConfig.port}`;
appConfig.baseUrl = baseUrl; appConfig.baseUrl = baseUrl;