Astro.preferredLocale
is always undefined
in "hybrid" output mode with prerender = false
#10620
Labels
- P3: minor bug
An edge case that only affects very specific usage (priority)
feat: i18n
Related to internalization
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
i want to use
Astro.preferredLocale
to redirect the "/" root route to the user's preferred locale (or the default locale). i am usinghybrid
output mode, and have setexport const prerender = false
insrc/pages/index.astro
, and configuredredirectToDefaultLocale: false
inastro.config.mjs
.When logging both
Astro.preferredLocale
andAstro.request.headers.get("Accept-Language")
, i see thatAstro.preferredLocale
isundefined
, even though theAccept-Language
headers are logged correctly.how to reproduce
pnpm run build
pnpm run preview
observations
hybrid
toserver
, it correctly prints: "Preferred locale: de"astro:i18n
, i.e. commenting out this line, it also works correctly in hybrid modesrc/pages/index.astro
to asrc/pages/index.ts
GET route does not make a differenceWhat's the expected result?
see above
Link to Minimal Reproducible Example
https://github.com/stefanprobst/issue-astro-i18n-preferredlocale-hybrid
Participation
The text was updated successfully, but these errors were encountered: