File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
packages/qwik-city/src/middleware/bun Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff 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 ( ) , {
You can’t perform that action at this time.
0 commit comments