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

Client side navigation with domain locales doesn't work for localhost (and any other domain) #22011

Closed
javiercr opened this issue Feb 10, 2021 · 6 comments · Fixed by #22032
Closed
Labels
bug Issue was opened via the bug report template.

Comments

@javiercr
Copy link

javiercr commented Feb 10, 2021

What version of Next.js are you using?

v10.0.5 to latest version (v10.0.7-canary.6 as of today)

What version of Node.js are you using?

v12.18.3 (should be replicable in any)

What browser are you using?

Any

What operating system are you using?

Any

How are you deploying your application?

next start

Describe the Bug

When using the i18n domain routing, client-side navigation is broken when using a domain not included in the domains config, such as localhost.

The problem was probably introduced with this change included on v10.0.5:
#20562

Expected Behavior

The domain routing config should only tell Next.js what's the current locale based on the current domain. If the domain doesn't match any of the domains in the config, it should fallback to the defaultLocale and client side navigation should use that domain for any Link.

To Reproduce

Here is a codesandox using the latest v10.0.7-canary.6 next:
https://codesandbox.io/s/next-i18n-domains-client-navigation-bug-bghx7

  1. Note that the config next.config.js has two domains defined (example.co.uk for en and example.es for es).
  2. Note that codesandbox will run the app under a codesandbox.io subdomain. If you were running the app locally you would be running it on localhost:3000, but the problem remains the same.
  3. Click on the "Go to secondary page" link.
  4. Observe how the browser is requesting example.co.uk/secondary and therefore client side navigation is broken under the codesandbox domain (or any other domain running the app).

Here is the same codesanbox using next v10.0.4:
https://codesandbox.io/s/next-i18n-domains-client-navigation-bug-next-v10-0-4-yhs5u
Client side navigation works as expected.

@javiercr javiercr added the bug Issue was opened via the bug report template. label Feb 10, 2021
@javiercr javiercr changed the title Client side navigation with domain locales doesn't work for localhost (and other domains) Client side navigation with domain locales doesn't work for localhost (and any other domain) Feb 10, 2021
@javiercr
Copy link
Author

Note this also affects the ability to use Vercel's deployment URLs:

If we have an app that uses example.co.uk and example.es for i18n routing, client side navigation is broken for any [deployment-id].vercel.app URL, so we can't test branches and PRs with Vercel anymore.

@javiercr
Copy link
Author

javiercr commented Feb 10, 2021

#21327 by @mokabyls seems to be related (if not the same). I'm keeping this one open as it includes a reproduction case.

@javiercr
Copy link
Author

javiercr commented Feb 10, 2021

And #21211 by @sebastian-nowak seems to be the same too.

@kodiakhq kodiakhq bot closed this as completed in #22032 Feb 11, 2021
kodiakhq bot pushed a commit that referenced this issue Feb 11, 2021
This updates to only create locale domain links if the current hostname is a locale domain to prevent making links unvisitable in development and preview environments where the configured locale domains don't point to the current build. 

Closes: #21211
Closes: #22011
@ijjk
Copy link
Member

ijjk commented Feb 11, 2021

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

@javiercr
Copy link
Author

Works perfectly, thank you!

@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
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants