chore: Adjust cors options

This commit is contained in:
Faruk AYDIN
2021-10-04 21:40:17 +02:00
committed by Ali BARIN
parent fc9bcc5c14
commit c0f022a1b0
6 changed files with 40 additions and 2 deletions

View File

@@ -2,12 +2,18 @@ import * as dotenv from 'dotenv';
dotenv.config();
type AppConfig = {
host: string,
protocol: string
port: string,
corsPort: string,
appEnv: string,
}
const appConfig: AppConfig = {
host: process.env.HOST || 'localhost',
protocol: process.env.PROTOCOL || 'http',
port: process.env.PORT || '3000',
corsPort: process.env.CORS_PORT || '3001',
appEnv: process.env.APP_ENV || 'development',
}

View File

@@ -0,0 +1,10 @@
import appConfig from './app'
const corsOptions = {
origin: `${appConfig.protocol}://${appConfig.host}:${appConfig.corsPort}`,
methods: 'POST',
credentials: true,
optionsSuccessStatus: 200,
}
export default corsOptions;