File tree Expand file tree Collapse file tree 4 files changed +44
-3
lines changed
test/production/empty-ssg-fallback Expand file tree Collapse file tree 4 files changed +44
-3
lines changed Original file line number Diff line number Diff line change @@ -1931,9 +1931,11 @@ export default abstract class Server<
1931
1931
if ( pathname === UNDERSCORE_NOT_FOUND_ROUTE ) {
1932
1932
pathname = '/404'
1933
1933
}
1934
- const is404Page = pathname === '/404'
1935
-
1936
- const is500Page = pathname === '/500'
1934
+ const isErrorPathname = pathname === '/_error'
1935
+ const is404Page =
1936
+ pathname === '/404' || ( isErrorPathname && res . statusCode === 404 )
1937
+ const is500Page =
1938
+ pathname === '/500' || ( isErrorPathname && res . statusCode === 500 )
1937
1939
const isAppPath = components . isAppPath === true
1938
1940
1939
1941
const hasServerProps = ! ! components . getServerSideProps
Original file line number Diff line number Diff line change
1
+ import { nextTestSetup } from 'e2e-utils'
2
+
3
+ describe ( 'empty-ssg-fallback' , ( ) => {
4
+ const { next } = nextTestSetup ( {
5
+ files : __dirname ,
6
+ } )
7
+
8
+ it ( 'should not cache 404 error page' , async ( ) => {
9
+ const res = await next . fetch ( '/any-non-existed' )
10
+ expect ( res . status ) . toBe ( 404 )
11
+ } )
12
+ } )
Original file line number Diff line number Diff line change
1
+ export const getStaticPaths = async ( ) => {
2
+ return {
3
+ paths : [ ] ,
4
+ fallback : 'blocking' ,
5
+ }
6
+ }
7
+ export const getStaticProps = async ( ) => {
8
+ return {
9
+ notFound : true ,
10
+ }
11
+ }
12
+
13
+ export default function Page ( ) {
14
+ return < p > slug</ p >
15
+ }
Original file line number Diff line number Diff line change
1
+ import { GetServerSidePropsContext } from 'next'
2
+
3
+ function Error ( { statusCode } : { statusCode : number } ) {
4
+ return < p > { statusCode ? `${ statusCode } error` : '500 error' } </ p >
5
+ }
6
+
7
+ export async function getServerSideProps ( { res } : GetServerSidePropsContext ) {
8
+ const statusCode = res ? res . statusCode : 404
9
+ return { props : { statusCode } }
10
+ }
11
+
12
+ export default Error
You can’t perform that action at this time.
0 commit comments