Files
Bram c8f41768f7
Build and Push Docker Images / build-and-push (push) Successful in 3m49s
basic playwright api
2025-11-20 14:46:07 +01:00

31 lines
696 B
JavaScript

const config = require('./config');
function authenticateApiKey(req, res, next) {
// If no API key is configured, skip authentication
if (!config.API_KEY) {
return next();
}
const providedKey = req.headers['x-api-key'];
if (!providedKey) {
return res.status(401).json({
error: 'Missing API key',
message: 'Please provide an API key in the x-api-key header',
});
}
if (providedKey !== config.API_KEY) {
return res.status(403).json({
error: 'Invalid API key',
message: 'The provided API key is not valid',
});
}
next();
}
module.exports = {
authenticateApiKey,
};