Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect with "asNeeded" in middleware always add locale to url #557

Closed
TommySorensen opened this issue Oct 10, 2023 · 3 comments
Closed
Labels
bug Something isn't working reproduction-missing unconfirmed Needs triage.

Comments

@TommySorensen
Copy link

Description

When using redirectreturned from createLocalizedPathnamesNavigation with localePrefix: 'as-needed', in the middleware, then the locale is always added to the url which it should not. It should never be added on the default locale.
This seems like a bug.

redirect({
    pathname: '/categories',
    params: { slug: ['hello'] }
})

I tried to create a codeSandbox, but it seems like the button calling the server actions never fires because of something with codesandbox.

Mandatory reproduction URL (CodeSandbox or GitHub repository)

https://codesandbox.io/p/sandbox/next-intl-bug-template-app-forked-cw69w9?file=%2Fsrc%2Fapp%2F%5Blocale%5D%2Faction.ts%3A1%2C1

Reproduction description

Click the button that calls the redirect function.

Expected behaviour

There should not be a locale in the url after redirect if you are on EN locale

@TommySorensen TommySorensen added bug Something isn't working unconfirmed Needs triage. labels Oct 10, 2023
@amannn
Copy link
Owner

amannn commented Oct 10, 2023

There seems to be a bug in the reproduction where the scripts don't load on the client side:

Screenshot 2023-10-10 at 13 55 23

I also see that when I download the Sandbox. Can you try to fix that? I noticed Next.js is slightly outdated.

As a side note, in your redirect you're missing the slug in the pathname.

Copy link

Thank you for your report.

Unfortunately, the reproduction is missing or incomplete, and as such we cannot investigate this issue. Please add a reproduction to the issue, otherwise it will be closed automatically.

Templates:

Creating a good bug report takes time.

To help us resolve the issue quickly, please simplify the reproduction as much as possible by removing any unnecessary code, files, and dependencies that are not directly related to the problem. The easier it is for us to see the issue, the faster we can help you.

Apart from the reproduction, make sure to include the precise steps on how to reproduce the issue, e.g.:

  1. Open reproduction
  2. Click on …
  3. See error: …

Thank you for your understanding!

FAQ

"I've included a reproduction, what is missing?"

This comment might have been added because your reproduction doesn't point to either a CodeSandbox or a public GitHub repository where the issue can be reproduced.

Please make sure:

  1. If you've linked to a CodeSandbox, make sure to save the latest changes.
  2. If you've linked to a GitHub repository, make sure that you've committed and pushed the latest changes.
  3. Linking to other resources, e.g. to the docs, unfortunately doesn't help to reproduce your issue.

Copy link

This issue has been automatically closed because it is missing a reproduction and there hasn't been any activity for 7 days. If the problem persists, please create a new bug report.

@github-actions github-actions bot added the Stale label Nov 22, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reproduction-missing unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

2 participants