Skip to content

Commit 1c2692e

Browse files
fix(bun qc): 404 for static paths (#6755)
Co-authored-by: Ken <[email protected]>
1 parent d589fac commit 1c2692e

File tree

1 file changed

+9
-0
lines changed
  • packages/qwik-city/src/middleware/bun

1 file changed

+9
-0
lines changed

packages/qwik-city/src/middleware/bun/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ export function createQwikCity(opts: QwikCityBunOptions) {
144144

145145
if (isStaticPath(request.method || 'GET', url)) {
146146
const { filePath, content } = await openStaticFile(url);
147+
// We know that it's in the static folder, but it could still be missing
148+
// If we start the stream with a missing file, it will throw a 500 error during the stream
149+
if (!(await content.exists())) {
150+
return new Response('Not Found', {
151+
status: 404,
152+
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'X-Not-Found': url.pathname },
153+
});
154+
}
155+
147156
const ext = extname(filePath).replace(/^\./, '');
148157

149158
return new Response(await content.stream(), {

0 commit comments

Comments
 (0)