-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[i18n] Fallback middleware intercepts 3xx redirects from page handlers, should only trigger on 404 #15688
Description
Astro Info
Astro v5.18.0
Vite v6.4.1
Node v22.20.0
System macOS (x64)
Package Manager npm
Output server
Adapter @astrojs/node (v9.5.4)
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Bug description:
When output: 'server' is used with i18n fallback configured, the fallback middleware intercepts 302 redirect responses returned by page handlers on non-default locale routes, and incorrectly replaces them with a redirect to the default-locale equivalent of the current page. The fallback should only trigger on 404 responses.
What's the expected result?
Expected result:
POST /en/example returns 302 Location: /en/success — the redirect target set by Astro.redirect() in the page handler.
Actual result:
POST /en/example returns 302 Location: /example — the German (default locale) equivalent of the current page. GET /en/example correctly returns 200; only requests where the handler itself produces a 3xx are affected.
Link to Minimal Reproducible Example
https://github.com/gabplanalp/astro-i18n-fallback-redirect-bug
Participation
- I am willing to submit a pull request for this issue.