Skip to content

Commit 5cecca7

Browse files
author
manish
committed
updated Index.js
1 parent 12ab00e commit 5cecca7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

server/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@ const cors = require('cors');
22
const express = require('express');
33
const connectDB = require('./db');
44
const { port } = require('./config');
5+
56
const app = express();
67

78
connectDB();
89

9-
// Enable CORS only for a specific origin
10-
const allowedOrigin = 'https://grep-many.github.io/NoteNest/'; // Replace with your allowed site URL
10+
// Allow only one origin
11+
const allowedOrigin = 'https://grep-many.github.io/NoteNest/';
1112
app.use(
1213
cors({
1314
origin: function (origin, callback) {
1415
if (origin === allowedOrigin || !origin) {
15-
// Allow requests from the allowed origin or server-side requests (no origin)
16+
// Allow requests from the allowed origin or server-side requests (no origin for internal use)
1617
callback(null, true);
1718
} else {
19+
// Reject other origins
1820
callback(new Error('Not allowed by CORS'));
1921
}
2022
},
23+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'], // Allow all HTTP methods
24+
credentials: true, // Allow cookies or authentication headers if needed
2125
})
2226
);
2327

0 commit comments

Comments
 (0)