Skip to content

i18n experimental routing creates a redirect page in the root #9300

@dallyh

Description

@dallyh

Astro Info

Astro                    v3.6.4
Node                     v18.17.1
System                   Windows (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/react
                         @astrojs/sitemap

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

No response

Describe the Bug

This may be more of a question, than an issue, However I'm not sure if it's the case,

So im fiddling with the new i18n router in SSG mode.

I have my pages setup with 2 locales, and pages arranged into folders with dynamic routes for [lang], using getStaticPaths() function. One of my pages in the root of pages is not in the [lang] folder, and it does not get generated,instead, a page with redirect (with meta refresh tag) to defaultLocale in the config is generated - that is when i access http://localhost:4321/ I get redirected to http://localhost:4321/cs/. This happens only when the prefixDefaultLocale is set to true.

image

Is this intended? Does and should the i18n router work well with getStaticPaths() dynamic routes?

If this is intended, then this should probably be mentioned in the docs. There is a mention that when prefixDefaultLocale is set to true all routes should be in the /locale/ folders, but nowhere (maybe i missed it) it says, that the root page is generated as a redirect. The structure even shows this page in the root, so I would assume that it does not get tempered with and it is generated as-is.

image

I had plans to use this page to detect user's prefered language from browser/storage and redirect the user myself, now it is not possible to do so.

If it is not intended and routing should not behave like this, then please tell me and I'll create a reproducible example.

Thanks!

What's the expected result?

When using i18n routing with prefixDefaultLocale is set to true the root page should be generated, and not altered to redirect to the defaultLocale.

Link to Minimal Reproducible Example

None for now, please see the description.

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