Skip to content

404 page doesn't show with i18n and prefixDefaultLocale enabled #12750

@Alejandro-FA

Description

@Alejandro-FA

Astro Info

Astro                    v5.0.6
Node                     v22.11.0
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/sitemap

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

No response

Describe the Bug

The bug is closely related to #12509, which was solved by #12525 when prefixDefaultLocale is set to false. However, the bug is still present when prefixDefaultLocale is set to true.

Test setup

  1. Open a new project and create localized folders, with a folder for the default locale too (i.e. prefixDefaultLocale set to true), as specified by the i18n guide.

  2. Create a 404.astro page in /pages.

Results

Visiting any URL prefixed with one of the supported languages shows the custom 404 page.

Visiting any URL without a valid language prefix shows a blank page.

Example

With ["es", "en", "fr"] as supported locales and en as the default locale:

/en/blabla => 404 page
/fr/blabla => 404 page

/blabla => blank page
/it/blabla => blank page

What's the expected result?

Any path that doesn't exist should show the custom 404 page.

Link to Minimal Reproducible Example

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

Participation

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

Metadata

Metadata

Assignees

Labels

- P4: importantViolate documented behavior or significantly impacts performance (priority)feat: i18nRelated to internalization (scope)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions