Skip to content

Commit

Permalink
Create apikey.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Mistydz authored Aug 14, 2021
1 parent fa4fbdf commit 2cab5ae
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions routes/apikey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require('dotenv').config();

const validateKey = (req, res, next) => {

let host = req.headers.host;
let api_key = req.query.api_key;


if (api_key == process.env.API_KEY && host == (process.env.HOST)) {
//good match
next();
} else {
//stop and respond
res.status(403).send({ error: { code: 403, message: 'Your not allowed to call this api.' } });
}
};

module.exports = { validateKey };

0 comments on commit 2cab5ae

Please sign in to comment.