Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task
Alejandro-FA opened this issue Dec 16, 2024 · 8 comments · Fixed by #12764
Closed
1 task

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

Alejandro-FA opened this issue Dec 16, 2024 · 8 comments · Fixed by #12764
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: i18n Related to internalization (scope)

Comments

@Alejandro-FA
Copy link

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.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 16, 2024
@Alejandro-FA
Copy link
Author

@ematipico Sorry to bother you, but I have seen that you solved the original bug some weeks ago. Are you able to reproduce this bug?

@ematipico
Copy link
Member

Please refrain from tagging me, especially since I haven't interacted with the issue.

@ematipico ematipico added - P4: important Violate documented behavior or significantly impacts performance (priority) feat: i18n Related to internalization (scope) and removed needs triage Issue needs to be triaged - P4: important Violate documented behavior or significantly impacts performance (priority) labels Dec 16, 2024
@ematipico
Copy link
Member

Closing, I can't reproduce the bug from the reproduction. It works as expected

@ematipico ematipico closed this as not planned Won't fix, can't repro, duplicate, stale Dec 17, 2024
@Alejandro-FA
Copy link
Author

Thank you for taking the time to review this issue and for your feedback. I understand that you were unable to reproduce the problem, where visiting a non-existing path without a locale prefix (like /test) correctly shows the custom 404 page. However, the bug remains reproducible on my end using the StackBlitz example.

To assist further, I’ve recorded a video that demonstrates the unexpected behavior:

Screencast.From.2024-12-17.12-50-41.mp4

In the video:

  1. Visiting /en/test correctly shows the custom 404 page.
  2. Visiting /test results in a blank page instead of the custom 404.
  3. Visiting /it/test shows a blank page as well (it is not a supported locale of the example).

If there’s a misunderstanding on my part about the expected behavior, I’d greatly appreciate clarification. Otherwise, I’d be grateful if you could take another look when time permits. If additional details about my environment or reproduction setup would be helpful, please let me know—I’m happy to assist further.

@ematipico
Copy link
Member

In your example, the it locale isn't defined, that's why you get a 404

@Alejandro-FA
Copy link
Author

Alejandro-FA commented Dec 17, 2024

Yes, I know that I should get a 404. However, instead of showing the 404 page defined in pages/404.astro, it just shows a blank page. I understand that any page that is not defined should show the 404 page implemented in pages/404.astro. At least, this is what happens if prefixDefaultLocale is set to false.

@ematipico ematipico reopened this Dec 17, 2024
@ematipico ematipico added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Dec 17, 2024
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 17, 2024
@ematipico ematipico self-assigned this Dec 17, 2024
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Dec 17, 2024
@ematipico
Copy link
Member

Sorry, using a path with a locale made things very confusing for me.

@Alejandro-FA
Copy link
Author

My bad, I should have explained the issue more clearly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: i18n Related to internalization (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants