Skip to content

Commit

Permalink
fix(bun qc): 404 for static paths (#6755)
Browse files Browse the repository at this point in the history
Co-authored-by: Ken <[email protected]>
  • Loading branch information
wmertens and KenAKAFrosty authored Aug 2, 2024
1 parent d589fac commit 1c2692e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/qwik-city/src/middleware/bun/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ export function createQwikCity(opts: QwikCityBunOptions) {

if (isStaticPath(request.method || 'GET', url)) {
const { filePath, content } = await openStaticFile(url);
// We know that it's in the static folder, but it could still be missing
// If we start the stream with a missing file, it will throw a 500 error during the stream
if (!(await content.exists())) {
return new Response('Not Found', {
status: 404,
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Not-Found': url.pathname },
});
}

const ext = extname(filePath).replace(/^\./, '');

return new Response(await content.stream(), {
Expand Down

0 comments on commit 1c2692e

Please sign in to comment.