nextjs - 💡(How to fix) Fix loading.tsx prevents returning correct HTTP redirect status (e.g. 308) [3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#84196Fetched 2026-04-08 02:20:18
View on GitHub
Comments
3
Participants
3
Timeline
6
Reactions
2
Timeline (top)
commented ×3issue_type_added ×1labeled ×1renamed ×1

Root Cause

  • Structure: root app/loading.tsx, app/redirect/page.tsx calls permanentRedirect('/target'), and app/target/page.tsx is a simple page.
  • Hit the running instance with root loading.tsx present:
  • curl -I https://dnc9yq-3000.csb.app/redirect Observed: Response is HTTP/2 200 with no Location header. (Because the presence of root loading.tsx causes the response to start as 200.)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8122
  Available memory (MB): 8192
  Available CPU cores: 8
Binaries:
  Node: 24.6.0
  npm: 11.5.1
  Yarn: 1.22.22
  pnpm: 10.14.0
Relevant Packages:
  next: 15.5.4 // Latest available version is detected (15.5.4).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.9.2
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/mutable-pond-dnc9yq

To Reproduce

Clone the repo or open the CodeSandbox minimal reproduction:

Start the dev server: pnpm dev

Minimal reproduction: https://dnc9yq-3000.csb.app

  • Structure: root app/loading.tsx, app/redirect/page.tsx calls permanentRedirect('/target'), and app/target/page.tsx is a simple page.

  • Hit the running instance with root loading.tsx present:

  • curl -I https://dnc9yq-3000.csb.app/redirect Observed: Response is HTTP/2 200 with no Location header. (Because the presence of root loading.tsx causes the response to start as 200.)

  • Now remove or rename app/loading.tsx and repeat:

  • curl -I https://dnc9yq-3000.csb.app/redirect Observed: Response is HTTP/2 308 with Location: /target.

Observation Summary:

With loading.tsx: /redirect returns 200. Without loading.tsx: /redirect returns 308 with a Location header.

Current vs. Expected behavior

Current Behavior

When app/loading.tsx is present, a request to /redirect returns HTTP 200 OK with no Location header and the redirect happens only on the client. When the loading.tsx file is removed, the same request correctly returns HTTP 308 Permanent Redirect with a Location header.

Expected Behavior

Even when a loading.tsx file exists, calling permanentRedirect() should result in the first HTTP response being 308 Permanent Redirect with a Location header.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8122
  Available memory (MB): 8192
  Available CPU cores: 8
Binaries:
  Node: 24.6.0
  npm: 11.5.1
  Yarn: 1.22.22
  pnpm: 10.14.0
Relevant Packages:
  next: 15.5.4 // Latest available version is detected (15.5.4).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.9.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Redirects

Which stage(s) are affected? (Select all that apply)

Other (Deployed)

Additional context

https://github.com/user-attachments/assets/e471dee9-07d7-4a4f-bc7e-5c94710572f8

extent analysis

TL;DR

The issue can be resolved by modifying the Next.js configuration to handle redirects correctly when a loading component is present.

Guidance

  • Verify that the permanentRedirect function is being called correctly in the page.tsx file and that it is not being overridden by any other configuration.
  • Check the Next.js documentation for any specific settings or configurations that need to be made to handle redirects with loading components.
  • Try modifying the next.config.js file to include a custom redirect handler that can handle the presence of a loading component.
  • Test the redirect functionality with and without the loading component to ensure that it is working as expected.

Example

No code example is provided as the issue is more related to configuration and setup.

Notes

The issue seems to be specific to the Next.js framework and its handling of redirects with loading components. The provided environment information and package versions may be relevant to the issue, but without more context, it's difficult to provide a more specific solution.

Recommendation

Apply a workaround by modifying the Next.js configuration to handle redirects correctly when a loading component is present. This is because the issue seems to be related to the framework's handling of redirects and loading components, and modifying the configuration may provide a more reliable solution than trying to upgrade to a fixed version.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix loading.tsx prevents returning correct HTTP redirect status (e.g. 308) [3 comments, 3 participants]