diff --git a/packages/next/src/server/app-render/action-handler.ts b/packages/next/src/server/app-render/action-handler.ts index eafba6c75866d3..1c91bc305e07dd 100644 --- a/packages/next/src/server/app-render/action-handler.ts +++ b/packages/next/src/server/app-render/action-handler.ts @@ -147,6 +147,7 @@ async function createRedirectRenderResult( req: IncomingMessage, res: ServerResponse, redirectUrl: string, + basePath: string, staticGenerationStore: StaticGenerationStore ) { res.setHeader('x-action-redirect', redirectUrl) @@ -158,7 +159,7 @@ async function createRedirectRenderResult( const host = req.headers['host'] const proto = staticGenerationStore.incrementalCache?.requestProtocol || 'https' - const fetchUrl = new URL(`${proto}://${host}${redirectUrl}`) + const fetchUrl = new URL(`${proto}://${host}${basePath}${redirectUrl}`) if (staticGenerationStore.revalidatedTags) { forwardedHeaders.set( @@ -612,6 +613,7 @@ To configure the body size limit for Server Actions, see: https://nextjs.org/doc req, res, redirectUrl, + ctx.renderOpts.basePath, staticGenerationStore ), }