fix: handle requests without authorization header

This commit is contained in:
Paul Bienkowski 2020-11-24 23:22:22 +01:00
parent 15edeb59e1
commit 393fc3dbb2

View file

@ -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);