File tree Expand file tree Collapse file tree 3 files changed +11
-26
lines changed
test/e2e/middleware-general/test Expand file tree Collapse file tree 3 files changed +11
-26
lines changed Original file line number Diff line number Diff line change @@ -180,7 +180,7 @@ export async function initialize(opts: {
180
180
removePathPrefix ( invokePath , config . basePath ) === '/404'
181
181
) {
182
182
res . setHeader ( 'x-nextjs-matched-path' , parsedUrl . pathname || '' )
183
- res . statusCode = 200
183
+ res . statusCode = 404
184
184
res . setHeader ( 'content-type' , 'application/json' )
185
185
res . end ( '{}' )
186
186
return null
Original file line number Diff line number Diff line change @@ -323,30 +323,17 @@ async function withMiddlewareEffects<T extends FetchDataOutput>(
323
323
return null
324
324
}
325
325
326
- try {
327
- const data = await options . fetchData ( )
326
+ const data = await options . fetchData ( )
328
327
329
- const effect = await getMiddlewareData (
330
- data . dataHref ,
331
- data . response ,
332
- options
333
- )
328
+ const effect = await getMiddlewareData ( data . dataHref , data . response , options )
334
329
335
- return {
336
- dataHref : data . dataHref ,
337
- json : data . json ,
338
- response : data . response ,
339
- text : data . text ,
340
- cacheKey : data . cacheKey ,
341
- effect,
342
- }
343
- } catch {
344
- /**
345
- * TODO: Revisit this in the future.
346
- * For now we will not consider middleware data errors to be fatal.
347
- * maybe we should revisit in the future.
348
- */
349
- return null
330
+ return {
331
+ dataHref : data . dataHref ,
332
+ json : data . json ,
333
+ response : data . response ,
334
+ text : data . text ,
335
+ cacheKey : data . cacheKey ,
336
+ effect,
350
337
}
351
338
}
352
339
@@ -2403,7 +2390,7 @@ export default class Router implements BaseRouter {
2403
2390
locale,
2404
2391
} ) ,
2405
2392
hasMiddleware : true ,
2406
- isServerRender : this . isSsr ,
2393
+ isServerRender : false ,
2407
2394
parseJSON : true ,
2408
2395
inflightCache : this . sdc ,
2409
2396
persistCache : ! this . isPreview ,
Original file line number Diff line number Diff line change @@ -104,14 +104,12 @@ describe('Middleware Runtime', () => {
104
104
function runTests ( { i18n } : { i18n ?: boolean } ) {
105
105
it ( 'should work with notFound: true correctly' , async ( ) => {
106
106
const browser = await next . browser ( '/ssr-page' )
107
- await browser . eval ( 'window.beforeNav = 1' )
108
107
await browser . eval ( 'window.next.router.push("/ssg/not-found-1")' )
109
108
110
109
await check (
111
110
( ) => browser . eval ( 'document.documentElement.innerHTML' ) ,
112
111
/ T h i s p a g e c o u l d n o t b e f o u n d /
113
112
)
114
- expect ( await browser . eval ( 'window.beforeNav' ) ) . toBe ( 1 )
115
113
116
114
await browser . refresh ( )
117
115
await check (
You can’t perform that action at this time.
0 commit comments