Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
8f6320c3
Unverified
Commit
8f6320c3
authored
Sep 04, 2026
by
Hendrik Liebau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide internal variant values from `headers()`
parent
9de70ca0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
0 deletions
+16
-0
request-store.ts
packages/next/src/server/async-storage/request-store.ts
+2
-0
variant-values.tsx
.../app-dir/variants/fixtures/default/app/variant-values.tsx
+5
-0
variants.test.ts
test/e2e/app-dir/variants/variants.test.ts
+9
-0
No files found.
packages/next/src/server/async-storage/request-store.ts
View file @
8f6320c3
...
@@ -10,6 +10,7 @@ import {
...
@@ -10,6 +10,7 @@ import {
NEXT_HTML_REQUEST_ID_HEADER
,
NEXT_HTML_REQUEST_ID_HEADER
,
NEXT_REQUEST_ID_HEADER
,
NEXT_REQUEST_ID_HEADER
,
}
from
'../../client/components/app-router-headers'
}
from
'../../client/components/app-router-headers'
import
{
NEXT_VARIANTS_HEADER
}
from
'../../lib/constants'
import
{
import
{
HeadersAdapter
,
HeadersAdapter
,
type
ReadonlyHeaders
,
type
ReadonlyHeaders
,
...
@@ -44,6 +45,7 @@ import type { OpaqueFallbackRouteParams } from '../request/fallback-params'
...
@@ -44,6 +45,7 @@ import type { OpaqueFallbackRouteParams } from '../request/fallback-params'
const
HIDDEN_REQUEST_HEADERS
:
ReadonlySet
<
string
>
=
new
Set
(
const
HIDDEN_REQUEST_HEADERS
:
ReadonlySet
<
string
>
=
new
Set
(
[
[
...
FLIGHT_HEADERS
,
...
FLIGHT_HEADERS
,
NEXT_VARIANTS_HEADER
,
// The client sends these dev-only request IDs so the server can route debug
// The client sends these dev-only request IDs so the server can route debug
// information back to the originating request. Like the flight headers,
// information back to the originating request. Like the flight headers,
// they are internal plumbing.
// they are internal plumbing.
...
...
test/e2e/app-dir/variants/fixtures/default/app/variant-values.tsx
View file @
8f6320c3
import
{
connection
}
from
'next/server'
import
{
connection
}
from
'next/server'
import
{
headers
}
from
'next/headers'
import
{
locale
,
theme
}
from
'../variants'
import
{
locale
,
theme
}
from
'../variants'
...
@@ -9,11 +10,15 @@ import { locale, theme } from '../variants'
...
@@ -9,11 +10,15 @@ import { locale, theme } from '../variants'
// above a read of one. Every caller of this component provides that boundary.
// above a read of one. Every caller of this component provides that boundary.
export
async
function
VariantValues
()
{
export
async
function
VariantValues
()
{
await
connection
()
await
connection
()
const
requestHeaders
=
await
headers
()
return
(
return
(
<>
<>
<
p
id=
"theme"
>
{
await
theme
()
}
</
p
>
<
p
id=
"theme"
>
{
await
theme
()
}
</
p
>
<
p
id=
"locale"
>
{
await
locale
()
}
</
p
>
<
p
id=
"locale"
>
{
await
locale
()
}
</
p
>
<
p
id=
"internal-variants-header"
>
{
requestHeaders
.
has
(
'x-next-internal-variants'
)
?
'present'
:
'absent'
}
</
p
>
</>
</>
)
)
}
}
test/e2e/app-dir/variants/variants.test.ts
View file @
8f6320c3
...
@@ -67,6 +67,15 @@ import { startExternalServer } from './external-server.mjs'
...
@@ -67,6 +67,15 @@ import { startExternalServer } from './external-server.mjs'
expect
(
response
.
headers
.
get
(
'x-next-internal-variants'
)).
toBeNull
()
expect
(
response
.
headers
.
get
(
'x-next-internal-variants'
)).
toBeNull
()
})
})
it
(
'should not expose the resolved values through `headers()`'
,
async
()
=>
{
const
$
=
await
next
.
render$
(
url
(
'/'
),
undefined
,
{
headers
:
{
cookie
:
'theme=dark'
},
})
expect
(
$
(
'#theme'
).
text
()).
toBe
(
'dark'
)
expect
(
$
(
'#internal-variants-header'
).
text
()).
toBe
(
'absent'
)
})
it
(
'should resolve a variant on the route the proxy rewrote to'
,
async
()
=>
{
it
(
'should resolve a variant on the route the proxy rewrote to'
,
async
()
=>
{
const
$
=
await
next
.
render$
(
url
(
'/rewrite-source'
),
undefined
,
{
const
$
=
await
next
.
render$
(
url
(
'/rewrite-source'
),
undefined
,
{
headers
:
{
cookie
:
'theme=dark'
},
headers
:
{
cookie
:
'theme=dark'
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment