Skip to content

Commit

Permalink
Update checkDomain.js
Browse files Browse the repository at this point in the history
  • Loading branch information
whogurdevil authored Jul 6, 2024
1 parent 75cb9d7 commit 729f72a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions backend/middleware/checkDomain.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
function checkDomain(req, res, next) {
const allowedCollegeDomain = 'gne1.gndec.ac.in';
const allowedVercelDomain ="training-tracker-gndec.vercel.app";
const allowedOnRenderDomain = "training-tracker-cse.onrender.com";
const origin = req.get('Origin') || req.get('Referer');

if (origin) {
const url = new URL(origin);
if (url.hostname === allowedCollegeDomain || url.hostname === allowedVercelDomain || url.hostname === allowedOnRenderDomain) {
if (url.hostname === allowedCollegeDomain || url.hostname === allowedVercelDomain) {
return next();
}
}

res.status(403).json({ message: 'Forbidden' });
}

module.exports = checkDomain;
module.exports = checkDomain;

0 comments on commit 729f72a

Please sign in to comment.