@@ -65,51 +65,6 @@ const generateLocaleRedirects = ({
65
65
return redirects
66
66
}
67
67
68
- const generate404Redirects = ( {
69
- staticRouteEntries,
70
- basePath,
71
- i18n,
72
- } : {
73
- staticRouteEntries : Array < [ string , SsgRoute ] >
74
- basePath : string
75
- i18n : NextConfig [ 'i18n' ]
76
- } ) : NetlifyConfig [ 'redirects' ] => {
77
- const redirects : NetlifyConfig [ 'redirects' ] = [ ]
78
-
79
- const isIsr404 = staticRouteEntries . some (
80
- ( [ route , { initialRevalidateSeconds } ] ) => is404Route ( route , i18n ) && initialRevalidateSeconds !== false ,
81
- )
82
-
83
- if ( isIsr404 ) {
84
- redirects . push ( {
85
- from : `${ basePath } /*` ,
86
- to : ODB_FUNCTION_PATH ,
87
- status : 404 ,
88
- } )
89
- } else if ( i18n ?. locales ?. length ) {
90
- i18n . locales . forEach ( ( locale ) => {
91
- redirects . push ( {
92
- from : `${ basePath } /${ locale } /*` ,
93
- to : `${ basePath } /server/pages/${ locale } /404.html` ,
94
- status : 404 ,
95
- } )
96
- } )
97
- redirects . push ( {
98
- from : `${ basePath } /*` ,
99
- to : `${ basePath } /server/pages/${ i18n . defaultLocale } /404.html` ,
100
- status : 404 ,
101
- } )
102
- } else {
103
- redirects . push ( {
104
- from : `${ basePath } /*` ,
105
- to : `${ basePath } /server/pages/404.html` ,
106
- status : 404 ,
107
- } )
108
- }
109
-
110
- return redirects
111
- }
112
-
113
68
export const generateStaticRedirects = ( {
114
69
netlifyConfig,
115
70
nextConfig : { i18n, basePath } ,
@@ -249,10 +204,9 @@ const generateDynamicRewrites = ({
249
204
return
250
205
}
251
206
if ( route . page in prerenderedDynamicRoutes ) {
252
- const { fallback } = prerenderedDynamicRoutes [ route . page ]
253
207
if ( matchesMiddleware ( middleware , route . page ) ) {
254
208
dynamicRoutesThatMatchMiddleware . push ( route . page )
255
- } else if ( fallback !== false ) {
209
+ } else {
256
210
dynamicRewrites . push (
257
211
...redirectsForNextRoute ( { buildId, route : route . page , basePath, to : ODB_FUNCTION_PATH , status : 200 , i18n } ) ,
258
212
)
@@ -342,7 +296,12 @@ export const generateRedirects = async ({
342
296
netlifyConfig . redirects . push ( ...dynamicRewrites )
343
297
routesThatMatchMiddleware . push ( ...dynamicRoutesThatMatchMiddleware )
344
298
345
- netlifyConfig . redirects . push ( ...generate404Redirects ( { staticRouteEntries, basePath, i18n } ) )
299
+ // Final fallback
300
+ netlifyConfig . redirects . push ( {
301
+ from : `${ basePath } /*` ,
302
+ to : HANDLER_FUNCTION_PATH ,
303
+ status : 200 ,
304
+ } )
346
305
347
306
const middlewareMatches = new Set ( routesThatMatchMiddleware ) . size
348
307
if ( middlewareMatches > 0 ) {
0 commit comments