Compare commits

..

3 Commits

Author SHA1 Message Date
JJ Kasper
fbb8bba4cf Publish Stable
- vercel@28.4.16
 - @vercel/next@3.2.10
2022-11-08 11:03:01 -08:00
JJ Kasper
56cc87fe9d [next] Handle skip normalize flag for middleware (#8873)
### Related Issues

x-ref: [slack
thread](https://vercel.slack.com/archives/C01224Q5M99/p1667927545637489?thread_ts=1664536480.045539&cid=C01224Q5M99)

### 📋 Checklist

<!--
  Please keep your PR as a Draft until the checklist is complete
-->

#### Tests

- [ ] The code changed/added as part of this PR has been covered with
tests
- [ ] All tests pass locally with `yarn test-unit`

#### Code Review

- [ ] This PR has a concise title and thorough description useful to a
reviewer
- [ ] Issue from task tracker has a link to this PR
2022-11-08 10:31:02 -08:00
JJ Kasper
0027ffa65b [next] Ensure rsc dynamic routes are correct (#8866)
### Related Issues

This ensures we properly route dynamic routes with segments in the
middle of the path for rsc paths and also ensures we normalize the
header values from the routes-manifest correctly.

x-ref: https://github.com/vercel/next.js/issues/42364
x-ref:
https://github.com/vercel/next.js/actions/runs/3415662540/jobs/5685787894

### 📋 Checklist

<!--
  Please keep your PR as a Draft until the checklist is complete
-->

#### Tests

- [ ] The code changed/added as part of this PR has been covered with
tests
- [ ] All tests pass locally with `yarn test-unit`

#### Code Review

- [ ] This PR has a concise title and thorough description useful to a
reviewer
- [ ] Issue from task tracker has a link to this PR
2022-11-08 07:24:32 -08:00
12 changed files with 99 additions and 29 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "28.4.15",
"version": "28.4.16",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Vercel",
@@ -44,7 +44,7 @@
"@vercel/build-utils": "5.5.7",
"@vercel/go": "2.2.15",
"@vercel/hydrogen": "0.0.29",
"@vercel/next": "3.2.9",
"@vercel/next": "3.2.10",
"@vercel/node": "2.6.2",
"@vercel/python": "3.1.24",
"@vercel/redwood": "1.0.34",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/next",
"version": "3.2.9",
"version": "3.2.10",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",

View File

@@ -1137,7 +1137,24 @@ export async function serverBuild({
}
}
const rscHeader = routesManifest.rsc?.header || '__rsc__';
const rscHeader = routesManifest.rsc?.header?.toLowerCase() || '__rsc__';
const completeDynamicRoutes: typeof dynamicRoutes = [];
if (appDir) {
for (const route of dynamicRoutes) {
completeDynamicRoutes.push(route);
completeDynamicRoutes.push({
...route,
src: route.src.replace(
new RegExp(escapeStringRegexp('(?:/)?$')),
'(?:\\.rsc)?(?:/)?$'
),
dest: route.dest?.replace(/($|\?)/, '.rsc$1'),
});
}
} else {
completeDynamicRoutes.push(...dynamicRoutes);
}
return {
wildcard: wildcardConfig,
@@ -1313,8 +1330,16 @@ export async function serverBuild({
// middleware comes directly after redirects but before
// beforeFiles rewrites as middleware is not a "file" route
...(routesManifest?.skipMiddlewareUrlNormalize
? denormalizeNextDataRoute(true)
: []),
...(isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
...(routesManifest?.skipMiddlewareUrlNormalize
? normalizeNextDataRoute(true)
: []),
...beforeFilesRewrites,
// Make sure to 404 for the /404 path itself
@@ -1504,7 +1529,7 @@ export async function serverBuild({
? // when resolving data routes for middleware we need to include
// all dynamic routes including non-SSG/SSP so that the priority
// is correct
dynamicRoutes
completeDynamicRoutes
.map(route => {
route = Object.assign({}, route);
let normalizedSrc = route.src;
@@ -1579,7 +1604,7 @@ export async function serverBuild({
// Dynamic routes (must come after dataRoutes as dataRoutes are more
// specific)
...dynamicRoutes,
...completeDynamicRoutes,
...(isNextDataServerResolving
? [

View File

@@ -213,6 +213,7 @@ type RoutesManifestOld = {
header: string;
varyHeader: string;
};
skipMiddlewareUrlNormalize?: boolean;
};
type RoutesManifestV4 = Omit<RoutesManifestOld, 'dynamicRoutes' | 'version'> & {

View File

@@ -2,8 +2,5 @@ module.exports = {
experimental: {
appDir: true,
runtime: 'experimental-edge',
serverComponents: true,
legacyBrowsers: false,
browsersListForSwc: true,
},
};

View File

@@ -15,7 +15,7 @@
"path": "/edge",
"status": 200,
"headers": {
"__rsc__": "1"
"RSC": "1"
},
"mustContain": "M1:{",
"mustNotContain": "<html"
@@ -24,7 +24,7 @@
"path": "/edge",
"status": 200,
"headers": {
"__rsc__": "1"
"RSC": "1"
},
"responseHeaders": {
"content-type": "application/octet-stream"
@@ -39,7 +39,7 @@
"path": "/",
"status": 200,
"headers": {
"__rsc__": "1"
"RSC": "1"
},
"mustContain": "M1:{",
"mustNotContain": "<html"
@@ -48,7 +48,7 @@
"path": "/",
"status": 200,
"headers": {
"__rsc__": "1"
"RSC": "1"
},
"responseHeaders": {
"content-type": "application/octet-stream"

View File

@@ -2,9 +2,6 @@ module.exports = {
experimental: {
appDir: true,
runtime: 'nodejs',
serverComponents: true,
legacyBrowsers: false,
browsersListForSwc: true,
},
rewrites: async () => {
return [

View File

@@ -11,14 +11,14 @@
"status": 200,
"mustContain": "hello from app/dashboard",
"responseHeaders": {
"vary": "__rsc__, __next_router_state_tree__, __next_router_prefetch__"
"vary": "RSC, Next-Router-State-Tree, Next-Router-Prefetch"
}
},
{
"path": "/dashboard",
"status": 200,
"headers": {
"__rsc__": "1"
"RSC": "1"
},
"mustContain": "M1:{",
"mustNotContain": "<html"
@@ -27,11 +27,11 @@
"path": "/dashboard",
"status": 200,
"headers": {
"__rsc__": "1"
"RSC": "1"
},
"responseHeaders": {
"content-type": "application/octet-stream",
"vary": "__rsc__, __next_router_state_tree__, __next_router_prefetch__"
"vary": "RSC, Next-Router-State-Tree, Next-Router-Prefetch"
}
},
{
@@ -63,7 +63,7 @@
"path": "/",
"status": 200,
"headers": {
"__rsc__": "1"
"RSC": "1"
},
"mustContain": "M1:{",
"mustNotContain": "<html"

View File

@@ -0,0 +1,10 @@
export default function DeploymentsPage(props) {
return (
<>
<p>
hello from app/dashboard/deployments/[id]/settings. ID is:{' '}
{props.params.id}
</p>
</>
);
}

View File

@@ -0,0 +1,3 @@
export default function Page() {
return <p>catchall</p>;
}

View File

@@ -2,9 +2,6 @@ module.exports = {
experimental: {
appDir: true,
runtime: 'nodejs',
serverComponents: true,
legacyBrowsers: false,
browsersListForSwc: true,
},
rewrites: async () => {
return [

View File

@@ -6,19 +6,59 @@
}
],
"probes": [
{
"path": "/dashboard/deployments/123/settings",
"status": 200,
"mustContain": "hello from app/dashboard/deployments/[id]/settings",
"responseHeaders": {
"vary": "RSC, Next-Router-State-Tree, Next-Router-Prefetch"
}
},
{
"path": "/dashboard/deployments/123/settings",
"status": 200,
"responseHeaders": {
"vary": "RSC, Next-Router-State-Tree, Next-Router-Prefetch"
},
"headers": {
"RSC": "1"
},
"mustContain": "M1:{",
"mustNotContain": "<html"
},
{
"path": "/dashboard/deployments/catchall/something",
"status": 200,
"mustContain": "catchall",
"responseHeaders": {
"vary": "RSC, Next-Router-State-Tree, Next-Router-Prefetch"
}
},
{
"path": "/dashboard/deployments/catchall/something",
"status": 200,
"responseHeaders": {
"vary": "RSC, Next-Router-State-Tree, Next-Router-Prefetch"
},
"headers": {
"RSC": "1"
},
"mustContain": "M1:{",
"mustNotContain": "<html"
},
{
"path": "/dashboard",
"status": 200,
"mustContain": "hello from app/dashboard",
"responseHeaders": {
"vary": "__rsc__, __next_router_state_tree__, __next_router_prefetch__"
"vary": "RSC, Next-Router-State-Tree, Next-Router-Prefetch"
}
},
{
"path": "/dashboard",
"status": 200,
"headers": {
"__rsc__": "1"
"RSC": "1"
},
"mustContain": "M1:{",
"mustNotContain": "<html"
@@ -27,11 +67,11 @@
"path": "/dashboard",
"status": 200,
"headers": {
"__rsc__": "1"
"RSC": "1"
},
"responseHeaders": {
"content-type": "application/octet-stream",
"vary": "__rsc__, __next_router_state_tree__, __next_router_prefetch__"
"vary": "RSC, Next-Router-State-Tree, Next-Router-Prefetch"
}
},
{
@@ -68,7 +108,7 @@
"path": "/",
"status": 200,
"headers": {
"__rsc__": "1"
"RSC": "1"
},
"mustContain": "M1:{",
"mustNotContain": "<html"