Skip to content

Commit 331a956

Browse files
committed
fix: added a vary header with RSC to get proper content-type
1 parent 1edaacb commit 331a956

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/runtime/src/templates/edge-shared/rsc-data.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,17 @@ export const getRscDataRouter = ({ routes: staticRoutes, dynamicRoutes }: Preren
6060
const debug = request.headers.has('x-next-debug-logging')
6161
const log = debug ? (...args: unknown[]) => console.log(...args) : noop
6262
const url = new URL(request.url)
63+
64+
// Set the 'vary' header to 'RSC' to ensure that we cache correctly for the different
65+
// possible mime types: application/octet-stream and text/html
66+
// See https://github.com/netlify/pod-ecosystem-frameworks/issues/352#issuecomment-1450364417
67+
request.headers.set('vary', 'RSC')
68+
6369
// If this is a static RSC request, rewrite to the data route
6470
if (request.headers.get('rsc') === '1') {
6571
log('Is rsc request')
6672
if (matchesRscRoute(url.pathname)) {
73+
// Create a 'vary' header with 'RSC' as the value
6774
request.headers.set('x-rsc-route', url.pathname)
6875
const target = rscifyPath(url.pathname)
6976
log('Rewriting to', target)

0 commit comments

Comments
 (0)