refont back express
This commit is contained in:
16
backend/config/cors.js
Normal file
16
backend/config/cors.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import dotenv from 'dotenv';
|
||||
import * as path from "node:path";
|
||||
|
||||
const envFile = `.env`;
|
||||
dotenv.config({ path: path.resolve(process.cwd(), envFile), override: true });
|
||||
|
||||
const allowedOrigin = process.env.ALLOWED_ORIGIN || 'http://localhost:4200';
|
||||
|
||||
const corsOptions = {
|
||||
origin: allowedOrigin,
|
||||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
||||
allowedHeaders: ['Content-Type', 'Authorization'],
|
||||
credentials: true,
|
||||
};
|
||||
|
||||
export default corsOptions;
|
||||
Reference in New Issue
Block a user