next-translate
next-translate copied to clipboard
Error: Invariant: attempted to hard navigate to the same URL
What happened?
Hi, I just connected my app to the error tracker and noticed a lot of errors only on localized versions of my website:
https://[domain-name]/[locale]
.
Source of all errors:
{snip} dLocale.addLocale(router.asPath,router.locale)))throw Error("Invariant: attempted to hard navigate to the same URL ".concat(url," ").concat( {snip}
Example log:
It seems that after navigation to the same url it can't find the [locale].json file. I've tested navigating to the same page multiple times using the link component both on production and development, but I haven't noticed any errors/warnings in the console.
I was using Next.js v12.2.4 but the error still persists after upgrading to v13. Does anyone know if next-translate can cause this behavior or is it more related to a bug on the next.js side and I should open a topic there.
Thanks
What version of this package are you using? 1.6.0
What operating system, Node.js, and npm version? Win 10, Node 18.12.0, npm 9.1.1
next.config.js
const nextTranslate = require("next-translate");
const { withSentryConfig } = require("@sentry/nextjs");
const moduleExports = {
...nextTranslate(),
sentry: {
hideSourceMaps: true,
},
};
const sentryWebpackPluginOptions = {
silent: true,
};
module.exports = withSentryConfig(moduleExports, sentryWebpackPluginOptions);
i18n.json
{
"locales": ["pl", "en", "es", "ru", "tr", "zh", "hi", "fr", "ar", "bn", "pt", "id", "de", "it"],
"defaultLocale": "pl",
"localeDetection": false,
"pages": {
"*": ["common"],
"/": ["index"],
}
}
We need more details. Can you provide a reproducible example?