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

Redirecting to locale domain #19174

Closed
bartoszhernas opened this issue Nov 14, 2020 · 4 comments · Fixed by #20562
Closed

Redirecting to locale domain #19174

bartoszhernas opened this issue Nov 14, 2020 · 4 comments · Fixed by #20562
Assignees
Milestone

Comments

@bartoszhernas
Copy link

Feature request

Is your feature request related to a problem? Please describe.

In NextJS 10 we are able to set different domains with different locales. Eg, in my case:
EN version is at: https://weddingfeud.com
PL version is at: https://weselnagra.pl

As far as I can see, nextjs won't redirect me to a different domain when I have a link with a new locale. I've added in the footer a language picker and it only changes locale on the current domain.

Describe the solution you'd like

I expected NextJS to automatically redirect me to the correct domain, eg. while being on .PL domain and switching to EN language, I would like to have NextJS redirect me to .COM domain that I specified in nextjs.config

Describe alternatives you've considered

A workaround is simple: language picker can just point to proper domains, but would be nice to have this as a part of NextJS functionality

@kachkaev
Copy link
Contributor

kachkaev commented Dec 28, 2020

I also noticed this. Despite that I have i18ndomains in next.config.js. <Link href="/hello" locale="xx" /> points to /xx/hello instead of my-domain-for.xx/hello (or xx.localhost:3000/hello locally).

@kodiakhq kodiakhq bot closed this as completed in #20562 Dec 30, 2020
kodiakhq bot pushed a commit that referenced this issue Dec 30, 2020
This ensures we detect domain specific locales and redirect them client-side. Tests have been added in the `i18n` suite to ensure the domain redirect is applied correctly during a client-side navigation

Fixes: #19174
@ijjk
Copy link
Member

ijjk commented Dec 30, 2020

Hi, this has been updated in the latest version of Next.js v10.0.5-canary.4, please update and give it a try!

@kachkaev
Copy link
Contributor

kachkaev commented Dec 30, 2020

Thanks @ijjk I just tried v10.0.5-canary.4 in one of my projects. Is it expected that <Link href="/hello" locale="xx" /> still points to /xx/hello, which is followed by a redirect on click? Two observations:

  • Having /xx/hello is probably not as good as my-domain-for.xx/hello SEO-wise

  • During local dev, having domains: [{domain: "xx.localhost", defaultLocale: "xx"}] means that the redirect from /xx/hello goes to https://xx.localhost/hello instead of http://xx.localhost:3000/hello (note the port and the protocol). This requires manual URL tweaking before the website in another locale can be viewed. What would be the suggested way forward here?

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants
@kachkaev @Timer @bartoszhernas @timneutkens @balazsorban44 @ijjk and others