File tree 3 files changed +13
-3
lines changed
3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -139,8 +139,8 @@ export const generateRedirects = async ({
139
139
)
140
140
}
141
141
} )
142
- // Add rewrites for all static SSR routes
143
- staticRoutes . forEach ( ( route ) => {
142
+ // Add rewrites for all static SSR routes. This is Next 12+
143
+ staticRoutes ? .forEach ( ( route ) => {
144
144
if ( staticRoutePaths . has ( route . page ) || isApiRoute ( route . page ) ) {
145
145
// Prerendered static routes are either handled by the CDN or are ISR
146
146
return
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ export interface RoutesManifest {
46
46
redirects : Redirect [ ]
47
47
headers : Header [ ]
48
48
dynamicRoutes : DynamicRoute [ ]
49
- staticRoutes : StaticRoute [ ]
49
+ staticRoutes ? : StaticRoute [ ]
50
50
dataRoutes : DataRoute [ ]
51
51
i18n : I18n
52
52
rewrites : Rewrites
Original file line number Diff line number Diff line change @@ -409,6 +409,16 @@ describe('onBuild()', () => {
409
409
expect ( readFileSync ( handlerFile , 'utf8' ) ) . toMatch ( `require("../../../.next/required-server-files.json")` )
410
410
expect ( readFileSync ( odbHandlerFile , 'utf8' ) ) . toMatch ( `require("../../../.next/required-server-files.json")` )
411
411
} )
412
+
413
+ test ( 'handles empty routesManifest.staticRoutes' , async ( ) => {
414
+ await moveNextDist ( )
415
+ const manifestPath = path . resolve ( '.next/routes-manifest.json' )
416
+ const routesManifest = await readJson ( manifestPath )
417
+ delete routesManifest . staticRoutes
418
+ await writeJSON ( manifestPath , routesManifest )
419
+ // The function is supposed to return undefined, but we want to check if it throws
420
+ expect ( await plugin . onBuild ( defaultArgs ) ) . toBeUndefined ( )
421
+ } )
412
422
} )
413
423
414
424
describe ( 'onPostBuild' , ( ) => {
You can’t perform that action at this time.
0 commit comments