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

i18n: fallbacks strip search params #12546

Open
1 task done
mtwilliams-code opened this issue Nov 27, 2024 · 0 comments
Open
1 task done

i18n: fallbacks strip search params #12546

mtwilliams-code opened this issue Nov 27, 2024 · 0 comments
Labels
needs triage Issue needs to be triaged

Comments

@mtwilliams-code
Copy link

Astro Info

Astro                    v4.16.16
Node                     v18.20.3
System                   Linux (x64)
Package Manager          unknown
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/svelte

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

No response

Describe the Bug

The i18n module allows you to configure fallbacks for locales that dont have explicit page files for them. The injected middleware will rewrite or redirect the request to the page/url with the configured fallback locale. The code to do so does not pass forward any search params in the url. This blocked an intended use case for us, and I cannot think of a reason why it should not be the standard behavior. The existing relevant code is

				if (fallbackType === 'rewrite') {
					return await context.rewrite(newPathname);
				} else {
					return context.redirect(newPathname);
				}

In the stackblitz you can use ?name=whatever and see the index page change, then see the localized version falling back to 'en' at /es, then see the index render with a rewrite without the search params at /es?name=whatever

What's the expected result?

It should pass forward the search params in the rewrite/redirect. thus:

				if (fallbackType === 'rewrite') {
					return await context.rewrite(newPathname + context.url.search);
				} else {
					return context.redirect(newPathname + context.url.search);
				}

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-gafyfx

Participation

  • I am willing to submit a pull request for this issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant