Skip to content

Commit

Permalink
Fix prefetch rewrite case for RSC
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed May 3, 2024
1 parent 4b0716b commit 4577857
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/src/server-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export async function serverBuild({
if (rewrite.src && rewrite.dest) {
rewrite.src = rewrite.src.replace(
/\/?\(\?:\/\)\?/,
'(?<rscsuff>(\\.prefetch)?\\.rsc)?(?:/)?'
`(?<rscsuff>${experimental.ppr ? '(\\.prefetch)?' : ''}\\.rsc)?(?:/)?`
);
let destQueryIndex = rewrite.dest.indexOf('?');

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Page() {
return (
<>
product page
</>
)
}
4 changes: 4 additions & 0 deletions packages/next/test/fixtures/00-app-dir-no-ppr/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ module.exports = {
source: '/rewritten-to-index',
destination: '/?fromRewrite=1',
},
{
source: '/to-product/:productId.html',
destination: '/products/:productId',
},
];
},
};
24 changes: 24 additions & 0 deletions packages/next/test/fixtures/00-app-dir-no-ppr/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@
}
],
"probes": [
{
"path": "/to-product/product-id.html",
"status": 200,
"mustContain": "<html"
},
{
"path": "/to-product/product-id.html",
"status": 200,
"mustNotContain": "<html",
"mustContain": ":",
"headers": {
"RSC": 1
}
},
{
"path": "/to-product/product-id.html",
"status": 200,
"mustNotContain": ".prefetch",
"mustContain": ":",
"headers": {
"RSC": 1,
"Next-Router-Prefetch": 1
}
},
{
"path": "/nested/blog-fallback-false/first",
"status": 200,
Expand Down

0 comments on commit 4577857

Please sign in to comment.