Handle both 'Bearer ' and 'Bearer' auth headers properly

This commit is contained in:
Alec LaLonde
2021-04-08 11:52:29 -06:00
committed by Alec LaLonde
parent 961d53ec79
commit 14317bda46

View File

@@ -11,7 +11,7 @@ const unauthorizedVariables = {
function getHeaderToken(req: Request): string | null {
const authHeader = req.headers.authorization;
if (!authHeader) return null;
if (authHeader.substring(0, 7) !== 'Bearer')
if (authHeader.substring(0, 6) !== 'Bearer')
throw new Error('invalid token type');
const token = authHeader.replace('Bearer', '').trim();