From 7dfdf4a427a460092f09490baaa71b2028a38cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20R=C3=ADos?= Date: Sun, 17 Sep 2023 14:11:16 +0200 Subject: [PATCH] fix: apply suggested changes Co-authored-by: Asher Gomez --- middleware/headers.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/middleware/headers.ts b/middleware/headers.ts index abb10c96f..6710e726d 100644 --- a/middleware/headers.ts +++ b/middleware/headers.ts @@ -5,13 +5,11 @@ export async function hardenHeaders( req: Request, ctx: MiddlewareHandlerContext, ) { + if ( + ctx.destination !== "route" || new URL(req.url).pathname.startsWith("/api") + ) return await ctx.next(); + const response = await ctx.next(); - const path = new URL(req.url).pathname.split("/")[1] || "/"; - const blacklist = [/api/]; - - if (blacklist.some((regex) => regex.test(path))) { - return response; - } const contentSecurityPolicy = [ "default-src 'self'",