Skip to content

Commit

Permalink
fix: shortcircuit preHandler hook for user defined assets
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Garajian authored and dziraf committed May 30, 2024
1 parent 3939e6f commit 8e67920
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/authentication/protected-routes.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ export const withProtectedRoutesHandler = (
): void => {
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))) {
fastifyApp.addHook("preHandler", async (request, reply) => {
const buildComponentRoute = AdminRouter.routes.find(
(r) => r.action === "bundleComponents"
)?.path;
const assets = [
...AdminRouter.assets.map((a) => a.path),
...Object.values(admin.options?.assets ?? {}).flat(),
];
if (assets.find((a) => request.url.match(a))) {
return;
} else if (buildComponentRoute && request.url.match(buildComponentRoute)) {
return;
Expand Down

0 comments on commit 8e67920

Please sign in to comment.