Unverified Commit fba3b9b0 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Ensure we normalize .rsc/.prefetch.rsc (#80409)

When we match a `.rsc` or `.prefetch.rsc` path we need to normalize the
URL used to not include this as it could leak through to the canonical
URL used for rendering and with `usePathname()`.

x-ref: [slack
thread](https://vercel.slack.com/archives/C08VDSLKNVC/p1749551233763969)
parent 0d7b49b1
...@@ -2637,7 +2637,7 @@ export default abstract class Server< ...@@ -2637,7 +2637,7 @@ export default abstract class Server<
const parsedInitUrl = parseUrl( const parsedInitUrl = parseUrl(
getRequestMeta(req, 'initURL') || req.url getRequestMeta(req, 'initURL') || req.url
) )
request.url = `${parsedInitUrl.pathname}${parsedInitUrl.search || ''}` request.url = `${parsedInitUrl.pathname?.replace(/(\.prefetch\.rsc|\.rsc)$/, '')}${parsedInitUrl.search || ''}`
// propagate the request context for dev // propagate the request context for dev
setRequestMeta(request, getRequestMeta(req)) setRequestMeta(request, getRequestMeta(req))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment