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(
body,
})
const location = res.headers.get('location')
const location = res.headers.get('x-action-redirect')
const redirectLocation = location
? new URL(addBasePath(location), window.location.origin)
......
......@@ -131,6 +131,7 @@ async function createRedirectRenderResult(
redirectUrl: string,
staticGenerationStore: StaticGenerationStore
) {
res.setHeader('x-action-redirect', redirectUrl)
// if we're redirecting to a relative path, we'll try to stream the response
if (redirectUrl.startsWith('/')) {
const forwardedHeaders = getForwardedHeaders(req, res)
......@@ -349,7 +350,6 @@ export async function handleAction({
// 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
res.setHeader('Location', redirectUrl)
await Promise.all(staticGenerationStore.pendingRevalidates || [])
if (isFetchAction) {
......@@ -361,6 +361,7 @@ export async function handleAction({
)
}
res.setHeader('Location', redirectUrl)
res.statusCode = 303
return new RenderResult('')
} 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