From e331da617b4d469085700236e07879c41a75d0e2 Mon Sep 17 00:00:00 2001 From: Mahdi Ghajary Date: Wed, 25 Oct 2023 15:17:12 +0330 Subject: [PATCH] Use manual CORS setting --- src/main.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 46da149..d4be82a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -18,7 +18,18 @@ async function bootstrap() { // app.enableCors(); // app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true })); app.useGlobalPipes(new ValidationPipe({ transform: true })); - app.use(cors()); + // app.use(cors()); + + app.use((req: any, res: any) => { + res.header('Access-Control-Allow-Origin', '*'); + res.header( + 'Access-Control-Allow-Headers', + 'Content-Type,Content-Length, Authorization, Accept,X-Requested-With, Auth', + ); + res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS'); + //... + }); + // app.use( // cors({ // credentials: true,