@@ -12,6 +12,7 @@ import {
12
12
localizeRoute ,
13
13
localizeDataRoute ,
14
14
unlocalizeRoute ,
15
+ getMatchedRoute ,
15
16
} from './handlerUtils'
16
17
17
18
interface NetlifyConfig {
@@ -50,7 +51,7 @@ const getNetlifyNextServer = (NextServer: NextServerType) => {
50
51
const { url, headers } = req
51
52
52
53
// conditionally use the prebundled React module
53
- this . netlifyPrebundleReact ( url )
54
+ this . netlifyPrebundleReact ( url , parsedUrl )
54
55
55
56
// intercept on-demand revalidation requests and handle with the Netlify API
56
57
if ( headers [ 'x-prerender-revalidate' ] && this . netlifyConfig . revalidateToken ) {
@@ -79,12 +80,12 @@ const getNetlifyNextServer = (NextServer: NextServerType) => {
79
80
}
80
81
81
82
// doing what they do in https://github.com/vercel/vercel/blob/1663db7ca34d3dd99b57994f801fb30b72fbd2f3/packages/next/src/server-build.ts#L576-L580
82
- private netlifyPrebundleReact ( path : string ) {
83
+ private netlifyPrebundleReact ( path : string , parsedUrl ? ) {
83
84
const routesManifest = this . getRoutesManifest ?.( )
84
85
const appPathsRoutes = this . getAppPathRoutes ?.( )
85
86
86
87
const routes = routesManifest && [ ...routesManifest . staticRoutes , ...routesManifest . dynamicRoutes ]
87
- const matchedRoute = routes ?. find ( ( route ) => new RegExp ( route . regex ) . test ( new URL ( path , 'http://n' ) . pathname ) )
88
+ const matchedRoute = getMatchedRoute ( path , routes , parsedUrl , this . nextConfig . basePath )
88
89
const isAppRoute = appPathsRoutes && matchedRoute ? appPathsRoutes [ matchedRoute . page ] : false
89
90
90
91
if ( isAppRoute ) {
0 commit comments