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();