mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 04:22:12 +00:00
[next] fix content-type for RSC prefetches (#10487)
This ensures that the `.prefetch.rsc` requests respond with the correct `content-type` since this is used by Next.js to determine if a request is valid or not (and in the case it's invalid, an mpa navigation will occur) Fixes: https://github.com/vercel/next.js/issues/54934
This commit is contained in:
@@ -48,6 +48,9 @@ export const MIB = 1024 * KIB;
|
||||
|
||||
export const prettyBytes = (n: number) => bytes(n, { unitSeparator: ' ' });
|
||||
|
||||
export const RSC_CONTENT_TYPE = 'x-component';
|
||||
export const RSC_PREFETCH_SUFFIX = '.prefetch.rsc';
|
||||
|
||||
// Identify /[param]/ in route string
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
const TEST_DYNAMIC_ROUTE = /\/\[[^\/]+?\](?=\/|$)/;
|
||||
@@ -2158,7 +2161,7 @@ export const onPrerenderRoute =
|
||||
routesManifest?.rsc?.varyHeader ||
|
||||
'RSC, Next-Router-State-Tree, Next-Router-Prefetch';
|
||||
const rscContentTypeHeader =
|
||||
routesManifest?.rsc?.contentTypeHeader || 'text/x-component';
|
||||
routesManifest?.rsc?.contentTypeHeader || RSC_CONTENT_TYPE;
|
||||
|
||||
let sourcePath: string | undefined;
|
||||
if (`/${outputPathPage}` !== srcRoute && srcRoute) {
|
||||
|
||||
Reference in New Issue
Block a user