Skip to content

Commit

Permalink
rituvercelLink
Browse files Browse the repository at this point in the history
  • Loading branch information
imdeveshshukla committed Aug 25, 2024
1 parent e28113f commit 02d3050
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions backend/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,29 @@ dotenv.config({
})
const app = express()
const port = 3000
const dep = (origin, callback) => {
const allowedOrigins = [
'https://www.bequiet.live',
'https://www.bequiet.vercel.app'
];
const allowedOrigins = [
'https://www.bequiet.live',
'https://www.bequiet.vercel.app'
];

if (allowedOrigins.includes(origin) || !origin) {
callback(null, true);
} else {
callback(new Error('Not allowed by CORS'));
}
};
const corsOptions = {
credentials: true,
origin: (process.env.NODE_ENV === 'development')?'http://localhost:5173':dep,
origin: (origin, callback) => {
if (process.env.NODE_ENV === 'development') {
if (origin === 'http://localhost:5173') {
callback(null, true);
} else {
callback(new Error('Not allowed by CORS'));
}
} else {
// Allow only specified origins in production
if (allowedOrigins.includes(origin) || !origin) {
callback(null, true);
} else {
callback(new Error('Not allowed by CORS'));
}
}
},
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
allowedHeaders: [
"Origin",
Expand Down

0 comments on commit 02d3050

Please sign in to comment.