i18n fallback does not work with manual routing #12431
Labels
- P3: minor bug
An edge case that only affects very specific usage (priority)
feat: i18n
Related to internalization (scope)
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
The
i18n.fallback
andi18n.routing.fallbackType
options are ignored by themiddleware
function fromastro:i18n
when using manual routing.As far as I understand, the following two setups should have the same behavior:
Configuration 1 (default routing middleware)
Configure
astro.config.mjs
to set the fallback of thees
locale toen
. Furthermore, specify thefallbackType
to"redirect"
.Configuration 2 (manual routing)
Configure
astro.config.mjs
to set the fallback of thees
locale toen
.Use the
middleware
function insrc/middleware.ts
to recover the default routing behavior (and set thefallbackType
to `"redirect" as done before)Behavior
With the first configuration, navigating to
/es
correctly redirects to/en
ifsrc/pages/es/index.astro
does not exist. However, with the second configuration, navigating to/es
throws a 404 error instead of redirecting to/en
.What's the expected result?
The
fallback
andfallbackType
options behave in manual routing exactly as in "automatic" routing.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-wtyvk1?file=src%2Fmiddleware.ts
Participation
The text was updated successfully, but these errors were encountered: