fix: handle requests without authorization header
This commit is contained in:
parent
15edeb59e1
commit
393fc3dbb2
|
@ -22,7 +22,8 @@ const jwtOptional = jwt({
|
|||
|
||||
function getUserIdMiddleware(req, res, next) {
|
||||
try {
|
||||
const [tokenType, token] = req.headers.authorization.split(' ') || [];
|
||||
const authorization = req.headers.authorization;
|
||||
const [tokenType, token] = (authorization && authorization.split(' ')) || [];
|
||||
|
||||
if (tokenType === 'Token' || tokenType === 'Bearer') {
|
||||
return jwtOptional(req, res, next);
|
||||
|
|
Loading…
Reference in a new issue