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
beecaf9f
Commit
beecaf9f
authored
Aug 03, 2025
by
Malte Ubl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In Progress: Add request header for server actions on inbound requests
parent
bbcdceaa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
3 deletions
+58
-3
index.ts
packages/next/src/build/index.ts
+49
-1
flight-client-entry-plugin.ts
...t/src/build/webpack/plugins/flight-client-entry-plugin.ts
+9
-2
No files found.
packages/next/src/build/index.ts
View file @
beecaf9f
...
@@ -3027,9 +3027,52 @@ export default async function build(
...
@@ -3027,9 +3027,52 @@ export default async function build(
// The htmlLimitedBots has been converted to a string during loadConfig
// The htmlLimitedBots has been converted to a string during loadConfig
config
.
htmlLimitedBots
||
HTML_LIMITED_BOT_UA_RE_STRING
config
.
htmlLimitedBots
||
HTML_LIMITED_BOT_UA_RE_STRING
// Generate specific routes for each server action
const
generateServerActionNameInjectionRoutes
=
():
RouteHas
[]
=>
{
const
manifest
=
appDir
?
(
require
(
path
.
join
(
distDir
,
SERVER_DIRECTORY
,
SERVER_REFERENCE_MANIFEST
+
'.json'
)
)
as
ActionManifest
)
:
null
const
routes
:
RouteHas
[]
=
[]
if
(
manifest
)
{
// Iterate over Node.js server actions
for
(
const
actionId
of
[
...
Object
.
keys
(
manifest
.
node
),
...
Object
.
keys
(
manifest
.
edge
),
])
{
const
action
=
manifest
.
node
[
actionId
]
||
manifest
.
edge
[
actionId
]
routes
.
push
({
type
:
'header'
,
key
:
ACTION_HEADER
,
value
:
actionId
,
transforms
:
[
{
type
:
'request.headers'
,
op
:
'append'
,
target
:
{
key
:
'x-server-action-name'
,
},
args
:
`
${
action
.
filename
}
#
${
action
.
exportedName
}
`
,
},
],
})
}
}
return
routes
}
const
serverActionNameInjectionRoutes
=
generateServerActionNameInjectionRoutes
()
// this flag is used to selectively bypass the static cache and invoke the lambda directly
// this flag is used to selectively bypass the static cache and invoke the lambda directly
// to enable server actions on static routes
// to enable server actions on static routes
const
bypassFor
:
RouteHas
[]
=
[
const
b
aseB
ypassFor
:
RouteHas
[]
=
[
{
type
:
'header'
,
key
:
ACTION_HEADER
},
{
type
:
'header'
,
key
:
ACTION_HEADER
},
{
{
type
:
'header'
,
type
:
'header'
,
...
@@ -3049,6 +3092,11 @@ export default async function build(
...
@@ -3049,6 +3092,11 @@ export default async function build(
:
[]),
:
[]),
]
]
const
bypassFor
:
RouteHas
[]
=
[
...
baseBypassFor
,
...
serverActionNameInjectionRoutes
,
]
// We should collect all the dynamic routes into a single array for
// We should collect all the dynamic routes into a single array for
// this page. Including the full fallback route (the original
// this page. Including the full fallback route (the original
// route), any routes that were generated with unknown route params
// route), any routes that were generated with unknown route params
...
...
packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts
View file @
beecaf9f
...
@@ -69,10 +69,14 @@ type Actions = {
...
@@ -69,10 +69,14 @@ type Actions = {
layer
:
{
layer
:
{
[
name
:
string
]:
string
[
name
:
string
]:
string
}
}
// The exported name of the server action function
exportedName
?:
string
// The filename where the server action is defined
filename
?:
string
}
}
}
}
type
ActionIdNamePair
=
{
id
:
string
;
exportedName
:
string
}
type
ActionIdNamePair
=
{
id
:
string
;
exportedName
:
string
;
filename
?:
string
}
export
type
ActionManifest
=
{
export
type
ActionManifest
=
{
// Assign a unique encryption key during production build.
// Assign a unique encryption key during production build.
...
@@ -628,6 +632,7 @@ export class FlightClientEntryPlugin {
...
@@ -628,6 +632,7 @@ export class FlightClientEntryPlugin {
Object
.
entries
(
actionIds
).
map
(([
id
,
exportedName
])
=>
({
Object
.
entries
(
actionIds
).
map
(([
id
,
exportedName
])
=>
({
id
,
id
,
exportedName
,
exportedName
,
filename
:
modResource
,
}))
}))
)
)
}
}
...
@@ -949,11 +954,13 @@ export class FlightClientEntryPlugin {
...
@@ -949,11 +954,13 @@ export class FlightClientEntryPlugin {
:
pluginState
.
serverActions
:
pluginState
.
serverActions
for
(
const
[,
actionsFromModule
]
of
actionsArray
)
{
for
(
const
[,
actionsFromModule
]
of
actionsArray
)
{
for
(
const
{
id
}
of
actionsFromModule
)
{
for
(
const
{
id
,
exportedName
,
filename
}
of
actionsFromModule
)
{
if
(
typeof
currentCompilerServerActions
[
id
]
===
'undefined'
)
{
if
(
typeof
currentCompilerServerActions
[
id
]
===
'undefined'
)
{
currentCompilerServerActions
[
id
]
=
{
currentCompilerServerActions
[
id
]
=
{
workers
:
{},
workers
:
{},
layer
:
{},
layer
:
{},
exportedName
:
exportedName
,
filename
:
filename
,
}
}
}
}
currentCompilerServerActions
[
id
].
workers
[
bundlePath
]
=
{
currentCompilerServerActions
[
id
].
workers
[
bundlePath
]
=
{
...
...
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