rsnext/test/e2e/app-dir/edge-route-rewrite
Zack Tanner 0f642dc340
fix rewrites to edge routes (#58797)
### What?
Rewrites to an edge route currently throw an invariant rather than properly serving up the page that is rewritten to.

### Why?
The `NextRequest` object that is provided to the edge route handler contains pathname information only for the "origin" request (e.g., when visiting `/one/example` which rewrites to `/two/example`, the pathname is still `/one/example`. This hits an invariant since the route matcher is unable to find `/one/example` since it does not exist.

### How?
This updates the module wrapper to grab the pathname from the route definition rather than the request object. For dynamic segments, we extract them from `request.nextUrl` since we know that even if `nextUrl` is referencing the origin path, the parameters it has are relevant for the rewrite. 

This adds the `getUtils` utility that's also used in base-server to handle the URL normalization, which also provides an interface for normalizing dynamic params from a `ParsedUrlQuery`.

Closes NEXT-1724
Fixes #48295
2023-11-23 05:25:00 +00:00
..
app fix rewrites to edge routes (#58797) 2023-11-23 05:25:00 +00:00
edge-route-rewrite.test.ts fix rewrites to edge routes (#58797) 2023-11-23 05:25:00 +00:00
middleware.ts fix rewrites to edge routes (#58797) 2023-11-23 05:25:00 +00:00
next.config.js fix rewrites to edge routes (#58797) 2023-11-23 05:25:00 +00:00