diff --git a/packages/astro-pagefind/src/pagefind.ts b/packages/astro-pagefind/src/pagefind.ts index d0be62c..ae7d3af 100644 --- a/packages/astro-pagefind/src/pagefind.ts +++ b/packages/astro-pagefind/src/pagefind.ts @@ -5,6 +5,7 @@ import sirv from "sirv"; export default function pagefind(): AstroIntegration { let outDir: string; + let assets: string | null; return { name: "pagefind", hooks: { @@ -25,6 +26,11 @@ export default function pagefind(): AstroIntegration { } else { outDir = fileURLToPath(config.outDir); } + if (config.build.assetsPrefix) { + assets = null; + } else { + assets = config.build.assets; + } }, "astro:server:setup": ({ server, logger }) => { if (!outDir) { @@ -39,7 +45,7 @@ export default function pagefind(): AstroIntegration { etag: true, }); server.middlewares.use((req, res, next) => { - if (req.url?.startsWith("/pagefind/")) { + if (req.url?.startsWith("/pagefind/") || (assets && req.url?.startsWith(`/${assets}/`))) { serve(req, res, next); } else { next();