Skip to content

Commit 9b415b5

Browse files
committed
fix: use native path matching for app routes
1 parent 9864890 commit 9b415b5

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/runtime/src/templates/server.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
localizeRoute,
1313
localizeDataRoute,
1414
unlocalizeRoute,
15-
joinPaths,
1615
} from './handlerUtils'
1716

1817
interface NetlifyConfig {
@@ -78,12 +77,11 @@ const getNetlifyNextServer = (NextServer: NextServerType) => {
7877
// doing what they do in https://github.com/vercel/vercel/blob/1663db7ca34d3dd99b57994f801fb30b72fbd2f3/packages/next/src/server-build.ts#L576-L580
7978
private netlifyPrebundleReact(path: string) {
8079
const routesManifest = this.getRoutesManifest?.()
81-
const appPathsManifest = this.getAppPathsManifest?.()
80+
const appPathsRoutes = this.getAppPathRoutes?.()
8281

8382
const routes = routesManifest && [...routesManifest.staticRoutes, ...routesManifest.dynamicRoutes]
84-
const matchedRoute = routes?.find((route) => new RegExp(route.regex).test(path.split('?')[0]))
85-
const isAppRoute =
86-
appPathsManifest && matchedRoute ? appPathsManifest[joinPaths(matchedRoute.page, 'page')] : false
83+
const matchedRoute = routes?.find((route) => new RegExp(route.regex).test(new URL(path, 'http://n').pathname))
84+
const isAppRoute = appPathsRoutes && matchedRoute ? appPathsRoutes[matchedRoute.page] : false
8785

8886
if (isAppRoute) {
8987
// app routes should use prebundled React

0 commit comments

Comments
 (0)