Skip to content

Commit

Permalink
Revert "Revert "fix(bun qc): 404 for static paths (QwikDev#6755)""
Browse files Browse the repository at this point in the history
This reverts commit 4d3173c.
  • Loading branch information
maiieul committed Aug 27, 2024
1 parent 295bc95 commit 92cb1cb
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 92cb1cb

Please sign in to comment.