From a0e0b6c632342845b0f8b1c4cc68917b1cb2ffbc Mon Sep 17 00:00:00 2001 From: jazzgrewal Date: Thu, 5 Oct 2023 15:01:12 -0700 Subject: [PATCH] allow cors from all origin --- backend/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/index.js b/backend/index.js index 84d2d46..14086a3 100644 --- a/backend/index.js +++ b/backend/index.js @@ -1,4 +1,5 @@ const express = require('express'); +const cors = require('cors'); const dotenv =require('dotenv'); const indexRoutes = require("./routes/indexRoutes"); const mailRoutes = require("./routes/mailRoutes"); @@ -8,7 +9,11 @@ dotenv.config({ path: './.env' }) const app = express(); + +// Configure CORS options +const corsOptions = {origin: '*'}; app.use(express.json()); +app.use(cors(corsOptions)); app.use('/api/', indexRoutes); app.use('/api/mail', mailRoutes);