Skip to content

Warning: Prop href did not match. Server: "https://dev-user.example.com/" Client: "/" #22130

@andresgutgon

Description

@andresgutgon

What version of Next.js are you using?

10.0.7-canary.8

What version of Node.js are you using?

12.16.3

What browser are you using?

Google Chrome Version 88.0.4324.146 (Official Build) (x86_64)

What operating system are you using?

Mac OS Big Sur 11.1

How are you deploying your application?

next start

Describe the Bug

With this next.config.js

module.exports = {
  i18n: {
    locales: ['en-US', 'it'],
    defaultLocale: 'it',
    domains: [
      {
        domain: 'dev-user.example.com',
        defaultLocale: 'it',
      }
    ]
  }
}

And this code:

<Link href="/">
  <a>Just a link</a>
</Link>

In development I'm watching these warings from React:

Warning: Prop `href` did not match. Server: "https://dev-user.example.com/" Client: "/"

Note that the domain is not example but I'm not on localhost

Expected Behavior

The expected behaviour is not having those warnigs. I think what React is trying to say is that the HTML generated by the server is different when is computed in the client.

If I switch my next.config.js from Next i18n Domain routing to Next i18n Sub-path routing these warnings are gone.

So my theory is that next/link is behaving differently in Server and Client somehow.

To Reproduce

Yes! I can reproduce. Here are the steps:

  1. Clone this repo. next@canary + nginx in a docker-compose
  2. run docker-compose up
  3. Change for a moment your /etc/hosts

My /etc/hosts has this line:

127.0.0.1 dev-user.example.com

After that you should see this error:
image

I think followed all the steps : ) Let me know if something is not clear.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions