Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[next] Update rsc header handling #8862

Merged
merged 1 commit into from Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/next/src/server-build.ts
Expand Up @@ -1137,6 +1137,8 @@ export async function serverBuild({
}
}

const rscHeader = routesManifest.rsc?.header || '__rsc__';

return {
wildcard: wildcardConfig,
images:
Expand Down Expand Up @@ -1390,7 +1392,7 @@ export async function serverBuild({
has: [
{
type: 'header',
key: '__rsc__',
key: rscHeader,
},
],
dest: path.posix.join('/', entryDirectory, '/index.rsc'),
Expand All @@ -1401,7 +1403,7 @@ export async function serverBuild({
has: [
{
type: 'header',
key: '__rsc__',
key: rscHeader,
},
],
dest: path.posix.join('/', entryDirectory, '/$1.rsc'),
Expand Down
11 changes: 9 additions & 2 deletions packages/next/src/utils.ts
Expand Up @@ -209,6 +209,10 @@ type RoutesManifestOld = {
defaultLocale: string;
}>;
};
rsc?: {
header: string;
varyHeader: string;
};
};

type RoutesManifestV4 = Omit<RoutesManifestOld, 'dynamicRoutes' | 'version'> & {
Expand Down Expand Up @@ -1991,6 +1995,9 @@ export const onPrerenderRoute =
allowQuery = [];
}
}
const rscVaryHeader =
routesManifest?.rsc?.varyHeader ||
'__rsc__, __next_router_state_tree__, __next_router_prefetch__';

prerenders[outputPathPage] = new Prerender({
expiration: initialRevalidate,
Expand All @@ -2008,7 +2015,7 @@ export const onPrerenderRoute =
...(isAppPathRoute
? {
initialHeaders: {
vary: '__rsc__, __next_router_state_tree__, __next_router_prefetch__',
vary: rscVaryHeader,
},
}
: {}),
Expand All @@ -2031,7 +2038,7 @@ export const onPrerenderRoute =
? {
initialHeaders: {
'content-type': 'application/octet-stream',
vary: '__rsc__, __next_router_state_tree__, __next_router_prefetch__',
vary: rscVaryHeader,
},
}
: {}),
Expand Down