From 913126b0b037bd4546db30823567a91e7d89190f Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Tue, 13 May 2025 13:26:33 +0200 Subject: [PATCH] fix: update temp patch for dynamic css loading --- main.ts | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/main.ts b/main.ts index 18d48de..e44c0bf 100644 --- a/main.ts +++ b/main.ts @@ -5,18 +5,27 @@ import { contentType } from 'jsr:@std/media-types@1/content-type' export const app = new App() app.use(staticFiles()) -// temp fix before updating cssBundler middleware +//TEMP fix before updating cssBundler middleware app.use(async (ctx) => { const response = await ctx.next() - if (response.status === 404 && !response.url.match(/\/chunk-\w+\.js.*/)) { + if ( + response.status === 404 && + !ctx.url.pathname.match(/\/js\/[0-9a-f]+\/\S+\.js/) + ) { const ext = ctx.url.pathname.split('.').at(-1) ?? '.bin' const mime = contentType(ext) ?? 'application/octet-stream' - const file = await Deno.readFile(`./_fresh/static/${ctx.url.pathname}`) - return new Response(file, { - headers: { - 'Content-Type': mime, - }, - }) + + try { + const file = await Deno.readFile(`./_fresh/static/${ctx.url.pathname}`) + return new Response(file, { + headers: { + 'Content-Type': mime, + }, + }) + } catch { + //TEMP don't handle specific error for now + return response + } } return response })