hozana / next-translate-routes

Flexible and translated routes for Next.js without custom server
MIT License
115 stars 30 forks source link

NextJS trailingSlash not supported #4

Open christoph-pflueger opened 2 years ago

christoph-pflueger commented 2 years ago

NextJS has an option to configure trailing slashes in URLs: https://nextjs.org/docs/api-reference/next.config.js/trailing-slash

At the moment, this option causes mismatches between server and client.

cvolant commented 2 years ago

Hi @git-chrisp, I added the trailing slash option to the next.config.js in the repo example, and I don't experience any problem. Could you give more details, or better, a reproduction of the bug?

christoph-pflueger commented 2 years ago

Reproduction: https://github.com/git-chrisp/next-translate-routes-nextjs-trailing-slash-bug

When visiting localhost:3000/de/ the following error is printed in the console:

next-dev.js?3515:32 Warning: Prop `href` did not match. Server: "/de/seite1" Client: "/de/seite1/"
cvolant commented 2 years ago

At first, I could not reproduce: I don't know why, but I did not get the warning on Firefox. I tried on Chromium - just in case - and I got it. I added a fix in the next release.

cvolant commented 2 years ago

Done. Please reopen this if it is not fixed for you.

artemkhalygov commented 1 year ago

@cvolant on next v13 I have the same problem.

stovein commented 1 year ago

Hi, I also get this error too while having trailing slash option true in next.config.js next-translate-routes: 1.9.1v next: 12.3.4v