/
NeGaTiVe333
/
BackendUni_Course1
Обзор
Документация
Войти
/
NeGaTiVe333
/
BackendUni_Course1
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/middleware/auth.js
12 строк
282 B
NeGaTiVe369
lab1
30 ноя 2025, 17:28
30 ноя 2025, 17:28
5109c88
Код
Авторство
О чём код?
function authMiddleware(req, res, next) { const apiKey = req.header('X-API-Key') if (!apiKey || apiKey !== process.env.API_KEY) { return res.status(401).json({ error: 'Unauthorized: invalid API key' }) } req.apiKey = apiKey next() } module.exports = authMiddleware