Skip to content

Infinite redirects on i18n fallback when setting fallback to default locale that without prefix. #13729

@razonyang

Description

@razonyang

Astro Info

$ npx astro info
Astro                    v5.7.9
Node                     v23.9.0
System                   Linux (x64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Astro.config.mjs as follows:

{
  // ...
  i18n: {
    defaultLocale: "en",
    locales: [
      { path: "en", codes: ["en", "en-US"] },
      { path: "zh-hans", codes: ["zh-hans", "zh-CN"] },
      { path: 'fr', codes: ['fr'] },
    ],
    routing: {
      prefixDefaultLocale: false,
      redirectToDefaultLocale: true,
      fallbackType: "redirect",
    },
    fallback: {
      "fr": "en",
    },
  },
  // ...
}

However, I got infinite redirects when accessing /fr.

Image

The redirect works when setting fallback as {"fr": "zh-hans"}, which has prefix locale on the URL.

What's the expected result?

Navigate to /fr (page not found) then redirect the default locale (/ in this case).

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-n1hg4cfb?file=astro.config.mjs

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions