next-i18next
next-i18next copied to clipboard
Missing query object while redirect by locale
🐛 Bug Report
When load url with another locale, do redirect. For example:
http://localhost:3000/en/oauth2/connect?foo=foo
redirects to http://localhost:3000/oauth2/connect?foo=foo
(if locale equal defaultLocale)
But in this case next-js router missing query params.
Locale ru contains
query: {
"foo": "foo"
}
But locale en after redirect has empty query object even asPath = "/oauth2/connect?foo=foo"
To Reproduce
- Set default locale.
- Create url with search params
- Go url with different locale
// Paste your code here
import { useRouter } from 'next/router';
export const App: React.FC = () => {
const router = useRouter();
console.log(`locale ${router.locale}`, router);
return null;
}
Expected behavior
react.query before and after redirect is equals.
Your Environment
I'm not sure this is an issue of next-i18next, but it may be an issue of next.js. Anyway, please provide a reproducible repository or codesandbox example.
Hi there,
Assuming that you're using router.push()
, can you try not enabling shallow routing ?
More info in the link: https://nextjs.org/docs/routing/shallow-routing#caveats
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
not stale