Version sin Vite.
This commit is contained in:
13
backend/middleware/auth.js
Normal file
13
backend/middleware/auth.js
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = (req, res, next) => {
|
||||
const authHeader = req.headers['authorization'];
|
||||
if (!authHeader) return res.status(403).json({ error: 'No se permite el acceso sin token' });
|
||||
|
||||
const token = authHeader.split(' ')[1];
|
||||
|
||||
// Aquí la lógica de validación de tu token
|
||||
if (token) {
|
||||
next(); // Si el token es válido, dejamos pasar
|
||||
} else {
|
||||
res.status(401).json({ error: 'Token inválido o expirado' });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user