File tree Expand file tree Collapse file tree 7 files changed +33
-21
lines changed
packages/qwik-router/src/middleware Expand file tree Collapse file tree 7 files changed +33
-21
lines changed Original file line number Diff line number Diff line change @@ -128,9 +128,10 @@ export function createQwikRouter(opts: QwikRouterAzureOptions): AzureFunction {
128
128
// In the development server, we replace the getNotFound function
129
129
// For static paths, we assign a static "Not Found" message.
130
130
// This ensures consistency between development and production environments for specific URLs.
131
- const notFoundHtml = isStaticPath ( req . method || 'GET' , url )
132
- ? 'Not Found'
133
- : getNotFound ( url . pathname ) ;
131
+ const notFoundHtml =
132
+ ! req . headers . accept ?. includes ( 'text/html' ) || isStaticPath ( req . method || 'GET' , url )
133
+ ? 'Not Found'
134
+ : getNotFound ( url . pathname ) ;
134
135
return {
135
136
status : 404 ,
136
137
headers : { 'Content-Type' : 'text/html; charset=utf-8' , 'X-Not-Found' : url . pathname } ,
Original file line number Diff line number Diff line change @@ -103,9 +103,11 @@ export function createQwikRouter(opts: QwikRouterBunOptions) {
103
103
// In the development server, we replace the getNotFound function
104
104
// For static paths, we assign a static "Not Found" message.
105
105
// This ensures consistency between development and production environments for specific URLs.
106
- const notFoundHtml = isStaticPath ( request . method || 'GET' , url )
107
- ? 'Not Found'
108
- : getNotFound ( url . pathname ) ;
106
+ const notFoundHtml =
107
+ ! request . headers . get ( 'accept' ) ?. includes ( 'text/html' ) ||
108
+ isStaticPath ( request . method || 'GET' , url )
109
+ ? 'Not Found'
110
+ : getNotFound ( url . pathname ) ;
109
111
return new Response ( notFoundHtml , {
110
112
status : 404 ,
111
113
headers : { 'Content-Type' : 'text/html; charset=utf-8' , 'X-Not-Found' : url . pathname } ,
Original file line number Diff line number Diff line change @@ -115,9 +115,11 @@ export function createQwikRouter(opts: QwikRouterCloudflarePagesOptions) {
115
115
// In the development server, we replace the getNotFound function
116
116
// For static paths, we assign a static "Not Found" message.
117
117
// This ensures consistency between development and production environments for specific URLs.
118
- const notFoundHtml = isStaticPath ( request . method || 'GET' , url )
119
- ? 'Not Found'
120
- : getNotFound ( url . pathname ) ;
118
+ const notFoundHtml =
119
+ ! request . headers . get ( 'accept' ) ?. includes ( 'text/html' ) ||
120
+ isStaticPath ( request . method || 'GET' , url )
121
+ ? 'Not Found'
122
+ : getNotFound ( url . pathname ) ;
121
123
return new Response ( notFoundHtml , {
122
124
status : 404 ,
123
125
headers : { 'Content-Type' : 'text/html; charset=utf-8' , 'X-Not-Found' : url . pathname } ,
Original file line number Diff line number Diff line change @@ -104,9 +104,11 @@ export function createQwikRouter(opts: QwikRouterDenoOptions) {
104
104
// In the development server, we replace the getNotFound function
105
105
// For static paths, we assign a static "Not Found" message.
106
106
// This ensures consistency between development and production environments for specific URLs.
107
- const notFoundHtml = isStaticPath ( request . method || 'GET' , url )
108
- ? 'Not Found'
109
- : getNotFound ( url . pathname ) ;
107
+ const notFoundHtml =
108
+ ! request . headers . get ( 'accept' ) ?. includes ( 'text/html' ) ||
109
+ isStaticPath ( request . method || 'GET' , url )
110
+ ? 'Not Found'
111
+ : getNotFound ( url . pathname ) ;
110
112
return new Response ( notFoundHtml , {
111
113
status : 404 ,
112
114
headers : { 'Content-Type' : 'text/html; charset=utf-8' , 'X-Not-Found' : url . pathname } ,
Original file line number Diff line number Diff line change @@ -77,9 +77,11 @@ export function createQwikRouter(opts: QwikRouterNetlifyOptions) {
77
77
// In the development server, we replace the getNotFound function
78
78
// For static paths, we assign a static "Not Found" message.
79
79
// This ensures consistency between development and production environments for specific URLs.
80
- const notFoundHtml = isStaticPath ( request . method || 'GET' , url )
81
- ? 'Not Found'
82
- : getNotFound ( url . pathname ) ;
80
+ const notFoundHtml =
81
+ ! request . headers . get ( 'accept' ) ?. includes ( 'text/html' ) ||
82
+ isStaticPath ( request . method || 'GET' , url )
83
+ ? 'Not Found'
84
+ : getNotFound ( url . pathname ) ;
83
85
return new Response ( notFoundHtml , {
84
86
status : 404 ,
85
87
headers : { 'Content-Type' : 'text/html; charset=utf-8' , 'X-Not-Found' : url . pathname } ,
Original file line number Diff line number Diff line change @@ -72,9 +72,10 @@ export function createQwikRouter(opts: QwikRouterNodeRequestOptions | QwikCityNo
72
72
// In the development server, we replace the getNotFound function
73
73
// For static paths, we assign a static "Not Found" message.
74
74
// This ensures consistency between development and production environments for specific URLs.
75
- const notFoundHtml = isStaticPath ( req . method || 'GET' , url )
76
- ? 'Not Found'
77
- : getNotFound ( url . pathname ) ;
75
+ const notFoundHtml =
76
+ ! req . headers . accept ?. includes ( 'text/html' ) || isStaticPath ( req . method || 'GET' , url )
77
+ ? 'Not Found'
78
+ : getNotFound ( url . pathname ) ;
78
79
res . writeHead ( 404 , {
79
80
'Content-Type' : 'text/html; charset=utf-8' ,
80
81
'X-Not-Found' : url . pathname ,
Original file line number Diff line number Diff line change @@ -104,9 +104,11 @@ export function createQwikRouter(opts: QwikRouterVercelEdgeOptions) {
104
104
// In the development server, we replace the getNotFound function
105
105
// For static paths, we assign a static "Not Found" message.
106
106
// This ensures consistency between development and production environments for specific URLs.
107
- const notFoundHtml = isStaticPath ( request . method || 'GET' , url )
108
- ? 'Not Found'
109
- : getNotFound ( url . pathname ) ;
107
+ const notFoundHtml =
108
+ ! request . headers . get ( 'accept' ) ?. includes ( 'text/html' ) ||
109
+ isStaticPath ( request . method || 'GET' , url )
110
+ ? 'Not Found'
111
+ : getNotFound ( url . pathname ) ;
110
112
return new Response ( notFoundHtml , {
111
113
status : 404 ,
112
114
headers : { 'Content-Type' : 'text/html; charset=utf-8' , 'X-Not-Found' : url . pathname } ,
You can’t perform that action at this time.
0 commit comments