Unverified Commit e09efd5e authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

land: Include charset=utf-8 with x-component Content-Type header (#50314)

Lands https://github.com/vercel/next.js/pull/50060 with lint fixes and
updated tests.

Closes: https://github.com/vercel/next.js/pull/50060

---------
Co-authored-by: 's avatarLeah Lundqvist <leah@pigeon.sh>
parent 027aa72f
......@@ -5,7 +5,8 @@ export const NEXT_ROUTER_STATE_TREE = 'Next-Router-State-Tree' as const
export const NEXT_ROUTER_PREFETCH = 'Next-Router-Prefetch' as const
export const NEXT_URL = 'Next-Url' as const
export const FETCH_CACHE_HEADER = 'x-vercel-sc-headers' as const
export const RSC_CONTENT_TYPE_HEADER = 'text/x-component' as const
export const RSC_CONTENT_TYPE_HEADER =
'text/x-component; charset=utf-8' as const
export const RSC_VARY_HEADER =
`${RSC}, ${NEXT_ROUTER_STATE_TREE}, ${NEXT_ROUTER_PREFETCH}` as const
......
......@@ -227,22 +227,26 @@ createNextDescribe(
})
}
it('should use text/x-component for flight', async () => {
it('should use text/x-component; charset=utf-8 for flight', async () => {
const res = await next.fetch('/dashboard/deployments/123', {
headers: {
['RSC'.toString()]: '1',
},
})
expect(res.headers.get('Content-Type')).toBe('text/x-component')
expect(res.headers.get('Content-Type')).toBe(
'text/x-component; charset=utf-8'
)
})
it('should use text/x-component for flight with edge runtime', async () => {
it('should use text/x-component; charset=utf-8 for flight with edge runtime', async () => {
const res = await next.fetch('/dashboard', {
headers: {
['RSC'.toString()]: '1',
},
})
expect(res.headers.get('Content-Type')).toBe('text/x-component')
expect(res.headers.get('Content-Type')).toBe(
'text/x-component; charset=utf-8'
)
})
it('should return the `vary` header from edge runtime', async () => {
......
......@@ -2586,7 +2586,7 @@ const runTests = (isDev = false, isTurbo = false) => {
],
rsc: {
header: 'RSC',
contentTypeHeader: 'text/x-component',
contentTypeHeader: 'text/x-component; charset=utf-8',
varyHeader: 'RSC, Next-Router-State-Tree, Next-Router-Prefetch',
},
})
......
......@@ -1460,7 +1460,7 @@ function runTests({ dev }) {
],
rsc: {
header: 'RSC',
contentTypeHeader: 'text/x-component',
contentTypeHeader: 'text/x-component; charset=utf-8',
varyHeader: 'RSC, Next-Router-State-Tree, Next-Router-Prefetch',
},
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment