chore: Adjust cors options
This commit is contained in:
@@ -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',
|
||||
}
|
||||
|
||||
|
10
packages/backend/src/config/cors-options.ts
Normal file
10
packages/backend/src/config/cors-options.ts
Normal 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;
|
Reference in New Issue
Block a user