From 21a8718f87d7409d61970139e39c2bb0c6cfe91c Mon Sep 17 00:00:00 2001 From: Ritesh Ghosh Date: Fri, 4 Oct 2024 12:24:31 +0530 Subject: [PATCH] feat: update allowed origins to include wildcard if env not present --- src/config/cors.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/config/cors.ts b/src/config/cors.ts index 9cbf836..8089522 100644 --- a/src/config/cors.ts +++ b/src/config/cors.ts @@ -1,11 +1,11 @@ -import cors from 'cors'; -import dotenv from 'dotenv'; +import cors from "cors"; +import { config } from "dotenv"; -dotenv.config(); +config(); const allowedOrigins = process.env.CORS_ALLOWED_ORIGINS ? process.env.CORS_ALLOWED_ORIGINS.split(",") - : ["http://localhost:4000"]; + : ["http://localhost:4000", "*"]; const corsConfig = cors({ origin: function (origin, callback) { @@ -16,10 +16,9 @@ const corsConfig = cors({ } }, methods: ["GET"], + maxAge: 600, credentials: true, optionsSuccessStatus: 200, - maxAge: 600, }); export default corsConfig; -