dashboard war nur kurz zu sehen
All checks were successful
Build & Push Image / build-image (push) Successful in 1m2s

This commit is contained in:
2026-03-02 18:50:23 +09:00
parent aa0c82e6d3
commit 8965ffc11b

View File

@@ -1,12 +1,14 @@
import jwt from 'jsonwebtoken'
function authMiddleware(req, res, next) {
const token = req.headers['authorization']
const authHeader = req.headers['authorization'] || req.headers['Authorization'];
if (!authHeader) { return res.status(401).json({ message: "No token provided" }) }
if (!token) { return res.status(401).json({ message: "No token provided" }) }
// support headers in the form: 'Bearer <token>' or just the token
const token = authHeader.startsWith('Bearer ') ? authHeader.split(' ')[1] : authHeader;
jwt.verify(token, process.env.JWT_SECRET, (err, decoded) => {
if(err) {return res.status(401).json({message: "Invalid token"})}
jwt.verify(token, process.env.JWT_SECRET, (err, decoded) => {
if (err) { return res.status(401).json({ message: "Invalid token" }) }
req.userId = decoded.id
next()
})