Unverified Commit 12a6827c authored by Jimmy Lai's avatar Jimmy Lai Committed by GitHub

actions: update location header (#49223)

parent fb12a6dc
...@@ -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)
......
...@@ -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)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment