Skip to content

Commit 8e67920

Browse files
Ali Garajiandziraf
Ali Garajian
authored andcommitted
fix: shortcircuit preHandler hook for user defined assets
1 parent 3939e6f commit 8e67920

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Diff for: src/authentication/protected-routes.handler.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ export const withProtectedRoutesHandler = (
77
): void => {
88
const { rootPath } = admin.options;
99

10-
fastifyApp.addHook('preHandler', async (request, reply) => {
11-
const buildComponentRoute = AdminRouter.routes.find((r) => r.action === 'bundleComponents')?.path
12-
if (AdminRouter.assets.find((asset) => request.url.match(asset.path))) {
10+
fastifyApp.addHook("preHandler", async (request, reply) => {
11+
const buildComponentRoute = AdminRouter.routes.find(
12+
(r) => r.action === "bundleComponents"
13+
)?.path;
14+
const assets = [
15+
...AdminRouter.assets.map((a) => a.path),
16+
...Object.values(admin.options?.assets ?? {}).flat(),
17+
];
18+
if (assets.find((a) => request.url.match(a))) {
1319
return;
1420
} else if (buildComponentRoute && request.url.match(buildComponentRoute)) {
1521
return;

0 commit comments

Comments
 (0)