Creates a 401 Unauthorized error. Use when authentication is missing, invalid, or expired.
401 Unauthorized
Error message (default: "Unauthorized")
"Unauthorized"
AppError with status 401 and code UNAUTHORIZED
AppError
401
UNAUTHORIZED
if (!token) return next(Unauthorized('Missing or invalid Authorization header')) Copy
if (!token) return next(Unauthorized('Missing or invalid Authorization header'))
Creates a
401 Unauthorizederror. Use when authentication is missing, invalid, or expired.