From 411e2a24d098f9f9e7ed68681555391a1a6911df Mon Sep 17 00:00:00 2001 From: Cameron Jackson Date: Fri, 30 Jun 2023 04:04:32 -0700 Subject: [PATCH] fix: fix issue with Authentication not leading to login page (#15) * Fix issue with Authentication not leading to login page Issue is outlined in #13 * fix: add missing parentheses * Update protected-routes.handler.ts Fixes Typescript error for optional `Object` --- src/authentication/protected-routes.handler.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/authentication/protected-routes.handler.ts b/src/authentication/protected-routes.handler.ts index b98dad7..1c85b26 100644 --- a/src/authentication/protected-routes.handler.ts +++ b/src/authentication/protected-routes.handler.ts @@ -8,9 +8,10 @@ export const withProtectedRoutesHandler = ( const { rootPath } = admin.options; fastifyApp.addHook('preHandler', async (request, reply) => { + const buildComponentRoute = AdminRouter.routes.find((r) => r.action === 'bundleComponents')?.path if (AdminRouter.assets.find((asset) => request.url.match(asset.path))) { return; - } else if (AdminRouter.routes.find((r) => r.action === 'bundleComponents')) { + } else if (buildComponentRoute && request.url.match(buildComponentRoute)) { return; } else if ( !request.url.startsWith(rootPath) ||