AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Missing Redirect: 'Manual' In CreateRedirectRenderResult Causes Server To Follow Redirect Chains, Leading To 500 Errors And Latency

The fetch call inside createRedirectRenderResult in Next.js Server Actions does not set redirect: 'manual', unlike createForwardedActionResponse. As a result, when a server action redirects to an internal route that subsequently redirects externally (common with OAuth/SSO), the server follows the entire redirect chain. This can exceed redirect limits and throw a 500 error, or cause unnecessary latency by fetching slow external pages before returning the redirect to the client.

highConfidence 95%Next.jsReact Server ComponentsRoute HandlersTurbopackAffected V14.xAffected V15.xAffected V16.x

Origin Analysis

Missing redirect: 'manual' in the fetch options of createRedirectRenderResult (packages/next/src/server/app-render/action-handler.ts), causing Node's fetch to auto-follow redirects server-side instead of returning the 3xx response for the client to handle.
1. Create a server action that calls redirect('/api/login'). 2. The route handler at /api/login calls redirect('https://external-oauth-provider.com/authorize?...'). 3. Wrap the server action in a client component <form action={...}> to go through the RSC action handler path. 4. Submit the form. Observe either a 500 error if the external URL has a long redirect chain, or a delay as the server fetches the external redirect target before responding.

Fixing Code Block

Edge Case Audit

This change alters the redirect handling flow: the server will no longer follow the redirect, relying entirely on the client to do so. If any downstream code or middleware depends on the server having already resolved the final destination (e.g., for logging, caching, or server-side cookie handling), it may behave differently. Additionally, older clients or Next.js versions that do not properly handle the x-action-redirect header might not follow the redirect correctly. Rollback is safe by removing the redirect: 'manual' option. Test OAuth/SSO flows thoroughly.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state