From 4ded6539312c0c23b4686aa7abb1d4ff36ce3de8 Mon Sep 17 00:00:00 2001 From: Amin Latifi Date: Fri, 11 Oct 2024 23:53:40 +0330 Subject: [PATCH] Better error handling on processing authentication token --- src/server/bootstrap.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/server/bootstrap.ts b/src/server/bootstrap.ts index 4a3bafeec..349c500b5 100644 --- a/src/server/bootstrap.ts +++ b/src/server/bootstrap.ts @@ -251,7 +251,10 @@ export async function bootstrap() { const { headers } = req; const authVersion = headers?.authversion || '1'; if (headers?.authorization) { - token = headers.authorization.split(' ')[1].toString(); + token = headers.authorization?.split(' ')[1].toString(); + if (!token) { + throw new Error('Authorization token is missing'); + } user = await authorizationHandler(authVersion as string, token); } }