Skip to content

Commit

Permalink
Rename __flight_router_state_tree__ and __flight_prefetch__ to __next_
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Sep 28, 2022
1 parent ad86a55 commit a54d8a3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions packages/next/client/components/app-router.client.tsx
Expand Up @@ -45,17 +45,17 @@ export async function fetchServerResponse(
): Promise<[FlightData: FlightData, canonicalUrlOverride: URL | undefined]> {
const headers: {
__rsc__: '1'
__flight_router_state_tree__: string
__flight_prefetch__?: '1'
__next_router_state_tree__: string
__next_router_prefetch__?: '1'
} = {
// Enable flight response
__rsc__: '1',
// Provide the current router state
__flight_router_state_tree__: JSON.stringify(flightRouterState),
__next_router_state_tree__: JSON.stringify(flightRouterState),
}
if (prefetch) {
// Enable prefetch response
headers.__flight_prefetch__ = '1'
headers.__next_router_prefetch__ = '1'
}

const res = await fetch(url.toString(), {
Expand Down
10 changes: 5 additions & 5 deletions packages/next/server/app-render.tsx
Expand Up @@ -580,8 +580,8 @@ function getScriptNonceFromHeader(cspHeaderValue: string): string | undefined {

const FLIGHT_PARAMETERS = [
'__rsc__',
'__flight_router_state_tree__',
'__flight_prefetch__',
'__next_router_state_tree__',
'__next_router_prefetch__',
] as const

function headersWithoutFlight(headers: IncomingHttpHeaders) {
Expand Down Expand Up @@ -651,7 +651,7 @@ export async function renderToHTMLOrFlight(
query = Object.assign({}, query)

const isFlight = req.headers.__rsc__ !== undefined
const isPrefetch = req.headers.__flight_prefetch__ !== undefined
const isPrefetch = req.headers.__next_router_prefetch__ !== undefined

// Handle client-side navigation to pages directory
if (isFlight && isPagesDir) {
Expand Down Expand Up @@ -685,8 +685,8 @@ export async function renderToHTMLOrFlight(
* Router state provided from the client-side router. Used to handle rendering from the common layout down.
*/
const providedFlightRouterState: FlightRouterState = isFlight
? req.headers.__flight_router_state_tree__
? JSON.parse(req.headers.__flight_router_state_tree__ as string)
? req.headers.__next_router_state_tree__
? JSON.parse(req.headers.__next_router_state_tree__ as string)
: {}
: undefined

Expand Down
4 changes: 2 additions & 2 deletions packages/next/server/internal-utils.ts
Expand Up @@ -8,8 +8,8 @@ const INTERNAL_QUERY_NAMES = [
// RSC
'__rsc__',
// Routing
'__flight_router_state_tree__',
'__flight_prefetch__',
'__next_router_state_tree__',
'__next_router_prefetch__',
] as const

const EXTENDED_INTERNAL_QUERY_NAMES = ['__nextDataReq'] as const
Expand Down
4 changes: 2 additions & 2 deletions packages/next/server/web/adapter.ts
Expand Up @@ -37,8 +37,8 @@ class NextRequestHint extends NextRequest {

const FLIGHT_PARAMETERS = [
'__rsc__',
'__flight_router_state_tree__',
'__flight_prefetch__',
'__next_router_state_tree__',
'__next_router_prefetch__',
] as const

export async function adapter(params: {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/middleware.js
Expand Up @@ -19,7 +19,7 @@ export function middleware(request) {
? 'rewrite'
: 'redirect'

const internal = ['__rsc__', '__flight_router_state_tree__']
const internal = ['__rsc__', '__next_router_state_tree__']
if (internal.some((name) => request.headers.has(name))) {
return NextResponse[method](new URL('/internal/failure', request.url))
}
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/app-dir/rsc-basic.test.ts
Expand Up @@ -92,8 +92,8 @@ describe('app dir - react server components', () => {
'__nextDefaultLocale',
'__nextIsNotFound',
'__rsc__',
'__flight_router_state_tree__',
'__flight_prefetch__',
'__next_router_state_tree__',
'__next_router_prefetch__',
]

const hasNextInternalQuery = inlineFlightContents.some((content) =>
Expand All @@ -113,7 +113,7 @@ describe('app dir - react server components', () => {
if (
headers.__rsc__ === '1' &&
// Prefetches also include `__rsc__`
headers.__flight_prefetch__ !== '1'
headers.__next_router_prefetch__ !== '1'
) {
hasFlightRequest = true
}
Expand Down Expand Up @@ -198,7 +198,7 @@ describe('app dir - react server components', () => {
return request.allHeaders().then((headers) => {
if (
headers.__rsc__ === '1' &&
headers.__flight_prefetch__ !== '1'
headers.__next_router_prefetch__ !== '1'
) {
hasFlightRequest = true
}
Expand Down

0 comments on commit a54d8a3

Please sign in to comment.