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
12a6827c
Unverified
Commit
12a6827c
authored
May 04, 2023
by
Jimmy Lai
Committed by
GitHub
May 04, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
actions: update location header (#49223)
parent
fb12a6dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
2 deletions
+3
-2
server-action-reducer.ts
...mponents/router-reducer/reducers/server-action-reducer.ts
+1
-1
action-handler.ts
packages/next/src/server/app-render/action-handler.ts
+2
-1
No files found.
packages/next/src/client/components/router-reducer/reducers/server-action-reducer.ts
View file @
12a6827c
...
@@ -53,7 +53,7 @@ async function fetchServerAction(
...
@@ -53,7 +53,7 @@ async function fetchServerAction(
body
,
body
,
})
})
const
location
=
res
.
headers
.
get
(
'
location
'
)
const
location
=
res
.
headers
.
get
(
'
x-action-redirect
'
)
const
redirectLocation
=
location
const
redirectLocation
=
location
?
new
URL
(
addBasePath
(
location
),
window
.
location
.
origin
)
?
new
URL
(
addBasePath
(
location
),
window
.
location
.
origin
)
...
...
packages/next/src/server/app-render/action-handler.ts
View file @
12a6827c
...
@@ -131,6 +131,7 @@ async function createRedirectRenderResult(
...
@@ -131,6 +131,7 @@ async function createRedirectRenderResult(
redirectUrl
:
string
,
redirectUrl
:
string
,
staticGenerationStore
:
StaticGenerationStore
staticGenerationStore
:
StaticGenerationStore
)
{
)
{
res
.
setHeader
(
'x-action-redirect'
,
redirectUrl
)
// if we're redirecting to a relative path, we'll try to stream the response
// if we're redirecting to a relative path, we'll try to stream the response
if
(
redirectUrl
.
startsWith
(
'/'
))
{
if
(
redirectUrl
.
startsWith
(
'/'
))
{
const
forwardedHeaders
=
getForwardedHeaders
(
req
,
res
)
const
forwardedHeaders
=
getForwardedHeaders
(
req
,
res
)
...
@@ -349,7 +350,6 @@ export async function handleAction({
...
@@ -349,7 +350,6 @@ export async function handleAction({
// if it's a fetch action, we don't want to mess with the status code
// if it's a fetch action, we don't want to mess with the status code
// and we'll handle it on the client router
// and we'll handle it on the client router
res
.
setHeader
(
'Location'
,
redirectUrl
)
await
Promise
.
all
(
staticGenerationStore
.
pendingRevalidates
||
[])
await
Promise
.
all
(
staticGenerationStore
.
pendingRevalidates
||
[])
if
(
isFetchAction
)
{
if
(
isFetchAction
)
{
...
@@ -361,6 +361,7 @@ export async function handleAction({
...
@@ -361,6 +361,7 @@ export async function handleAction({
)
)
}
}
res
.
setHeader
(
'Location'
,
redirectUrl
)
res
.
statusCode
=
303
res
.
statusCode
=
303
return
new
RenderResult
(
''
)
return
new
RenderResult
(
''
)
}
else
if
(
isNotFoundError
(
err
))
{
}
else
if
(
isNotFoundError
(
err
))
{
...
...
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