From 4cb44a099cc3c3274622c382713f06a113c2aff3 Mon Sep 17 00:00:00 2001 From: Aydan Pirani Date: Sun, 14 Apr 2024 18:02:38 -0500 Subject: [PATCH] Allowing everything for cors --- src/middleware/cors-middleware.ts | 44 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/middleware/cors-middleware.ts b/src/middleware/cors-middleware.ts index 72f3d01..be5e39f 100644 --- a/src/middleware/cors-middleware.ts +++ b/src/middleware/cors-middleware.ts @@ -1,25 +1,25 @@ import cors from "cors"; -// Allow CORS for Netlify deploy previews -const allowedOrigins = ["https://reflectionsprojections.org"]; -// Function to check if the origin matches the deploy preview format -function isNetlifyDeployPreview(origin: string) { - const regex = new RegExp("deploy-preview-[0-9]*(--rp2024.netlify.app)(.*)"); - return regex.test(origin); -} +// // Allow CORS for Netlify deploy previews +// const allowedOrigins = ["https://reflectionsprojections.org"]; +// // Function to check if the origin matches the deploy preview format +// function isNetlifyDeployPreview(origin: string) { +// const regex = new RegExp("deploy-preview-[0-9]*(--rp2024.netlify.app)(.*)"); +// return regex.test(origin); +// } +// +// const corsMiddleware = cors({ +// origin: function (origin, callback) { +// if ( +// !origin || +// allowedOrigins.includes(origin) || +// isNetlifyDeployPreview(origin) +// ) { +// callback(null, true); +// } else { +// callback(new Error("Not allowed by CORS")); +// } +// }, +// }); -const corsMiddleware = cors({ - origin: function (origin, callback) { - if ( - !origin || - allowedOrigins.includes(origin) || - isNetlifyDeployPreview(origin) - ) { - callback(null, true); - } else { - callback(new Error("Not allowed by CORS")); - } - }, -}); - -export default corsMiddleware; +export default cors();