mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
In a deployed environment, `onCacheEntryV2` determines whether a postponed response is HTML-origin or RSC-origin by checking whether meta.url ends with `.rsc`. For some dynamic full-route RSC requests, Next was passing a URL with query params into onCacheEntry, for example: `/[tenant]/samples.rsc?nxtPtenant=tenant-x` Because that string does not end with .rsc, `onCacheEntryV2` misclassified the request as HTML and treated it as text/html instead of an RSC response. This PR normalizes the URL before passing it to `onCacheEntry`, so the callback receives the pathname rather than the full URL-with-query. --------- Co-authored-by: JJ Kasper <[email protected]>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('ppr-root-param-rsc-fallback', () => {
|
|
const { next, isNextDev } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
if (isNextDev) {
|
|
it('skipped in dev', () => {})
|
|
return
|
|
}
|
|
|
|
it('does not return HTML for a pregenerated root param full-route rsc request', async () => {
|
|
const response = await next.fetch(`/tenant-a/samples`, {
|
|
headers: {
|
|
RSC: '1',
|
|
},
|
|
})
|
|
const body = await response.text()
|
|
const contentType = response.headers.get('content-type') ?? ''
|
|
|
|
expect(response.status).toBe(200)
|
|
expect(contentType).toContain('text/x-component')
|
|
expect(body).not.toContain('<!DOCTYPE html>')
|
|
})
|
|
|
|
it('does not return HTML for a non-pregenerated root param full-route rsc request', async () => {
|
|
const tenant = `tenant-${Date.now()}`
|
|
const response = await next.fetch(`/${tenant}/samples`, {
|
|
headers: {
|
|
RSC: '1',
|
|
},
|
|
})
|
|
const body = await response.text()
|
|
const contentType = response.headers.get('content-type') ?? ''
|
|
|
|
expect(response.status).toBe(200)
|
|
expect(contentType).toContain('text/x-component')
|
|
expect(body).not.toContain('<!DOCTYPE html>')
|
|
})
|
|
})
|