next-i18next icon indicating copy to clipboard operation
next-i18next copied to clipboard

Missing query object while redirect by locale

Open Fi1osof opened this issue 2 years ago • 3 comments

🐛 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. Screenshot from 2022-07-07 19-26-45

Locale ru contains

query: {
    "foo": "foo"
}

But locale en after redirect has empty query object even asPath = "/oauth2/connect?foo=foo"

To Reproduce

  1. Set default locale.
  2. Create url with search params
  3. 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

Fi1osof avatar Jul 07 '22 16:07 Fi1osof

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.

adrai avatar Jul 07 '22 16:07 adrai

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

CallmeHongmaybe avatar Jul 08 '22 04:07 CallmeHongmaybe

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.

stale[bot] avatar Aug 12 '22 00:08 stale[bot]

not stale

techquestions avatar Sep 29 '22 20:09 techquestions