Repository: vercel/next.js
Pull request: Rename `rewroteURL` to `rewrittenPathname` in request metadata

The field stores a pathname, not a full URL.

Changed files:
filename: packages/next/src/server/app-render/app-render.tsx
patch: @@ -2023,9 +2023,8 @@ async function renderToHTMLOrFlightImpl(
   // fetch cache. Using the destination path ensures that
   // revalidatePath('/dest') invalidates cache entries for pages rewritten to
   // that destination.
-  // TODO: simplify getImplicitTags to accept pathname instead of url object,
-  // and rename 'rewroteURL' to 'rewrittenPathname' in request-meta.ts.
-  const rewrittenPathname = getRequestMeta(req, 'rewroteURL')
+  // TODO: simplify getImplicitTags to accept pathname instead of url object.
+  const rewrittenPathname = getRequestMeta(req, 'rewrittenPathname')
   const implicitTagsUrl = rewrittenPathname
     ? { ...url, pathname: rewrittenPathname }
     : url

filename: packages/next/src/server/base-server.ts
patch: @@ -1207,7 +1207,11 @@ export default abstract class Server<
             pathnameBeforeRewrite !== rewrittenParsedUrl.pathname
 
           if (didRewrite && rewrittenParsedUrl.pathname) {
-            addRequestMeta(req, 'rewroteURL', rewrittenParsedUrl.pathname)
+            addRequestMeta(
+              req,
+              'rewrittenPathname',
+              rewrittenParsedUrl.pathname
+            )
           }
 
           const routeParamKeys = new Set<string>()
@@ -1502,7 +1506,7 @@ export default abstract class Server<
 
         if (parsedUrl.pathname !== parsedMatchedPath.pathname) {
           parsedUrl.pathname = parsedMatchedPath.pathname
-          addRequestMeta(req, 'rewroteURL', invokePathnameInfo.pathname)
+          addRequestMeta(req, 'rewrittenPathname', invokePathnameInfo.pathname)
         }
         const normalizeResult = normalizeLocalePath(
           removePathPrefix(parsedUrl.pathname, this.nextConfig.basePath || ''),
@@ -2086,12 +2090,13 @@ export default abstract class Server<
       }
     }
 
-    // Compute the iSSG cache key. We use the rewroteUrl since
+    // Compute the iSSG cache key. We use the rewritten pathname since
     // pages with fallback: false are allowed to be rewritten to
     // and we need to look up the path by the rewritten path
     let urlPathname = parseUrl(req.url || '').pathname || '/'
 
-    let resolvedUrlPathname = getRequestMeta(req, 'rewroteURL') || urlPathname
+    let resolvedUrlPathname =
+      getRequestMeta(req, 'rewrittenPathname') || urlPathname
 
     this.setVaryHeader(req, res, isAppPath, resolvedUrlPathname)
 
@@ -2616,8 +2621,8 @@ export default abstract class Server<
               url: ctx.req.url,
               matchedPath: ctx.req.headers[MATCHED_PATH_HEADER],
               initUrl: getRequestMeta(ctx.req, 'initURL'),
-              didRewrite: !!getRequestMeta(ctx.req, 'rewroteURL'),
-              rewroteUrl: getRequestMeta(ctx.req, 'rewroteURL'),
+              didRewrite: !!getRequestMeta(ctx.req, 'rewrittenPathname'),
+              rewrittenPathname: getRequestMeta(ctx.req, 'rewrittenPathname'),
             },
             null,
             2

filename: packages/next/src/server/request-meta.ts
patch: @@ -81,9 +81,10 @@ export interface RequestMeta {
   didStripLocale?: boolean
 
   /**
-   * If the request had it's URL rewritten, this is the URL it was rewritten to.
+   * If the request had its URL rewritten, this is the pathname it was rewritten
+   * to (not a full URL, just the pathname).
    */
-  rewroteURL?: string
+  rewrittenPathname?: string
 
   /**
    * The cookies that were added by middleware and were added to the response.