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

Middleware causing full page reload when Link has prefetch={false} #460

Closed
zipme opened this issue Aug 18, 2023 · 8 comments
Closed

Middleware causing full page reload when Link has prefetch={false} #460

zipme opened this issue Aug 18, 2023 · 8 comments
Labels
bug Something isn't working reproduction-missing unconfirmed Needs triage.

Comments

@zipme
Copy link

zipme commented Aug 18, 2023

Description

When the has prefetch={false}, navigation would cause a full page reload, this happens when middleware is being used.

Mandatory reproduction URL (CodeSandbox or GitHub repository)

https://codesandbox.io/p/sandbox/adoring-tu-8k2j6f?file=/app/[locale]/page.tsx:5,1-6,1

Reproduction description

Steps to reproduce:

  1. Open reproduction
  2. Click on 'bar' link, things works normally and no full page reload, then you click on the home link
  3. Open network inspector/tab you can see the doc '/' got loaded.

Expected behaviour

Should behave like a SPA intead of full page reload

@zipme zipme added bug Something isn't working unconfirmed Needs triage. labels Aug 18, 2023
@amannn
Copy link
Owner

amannn commented Aug 21, 2023

In your reproduction I don't get a full reload when I click on the "bar" link and I also don't see any functionality from next-intl used in any relevant files.

Am I missing something?

@github-actions
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.

@github-actions
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 Aug 29, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2023
@zipme
Copy link
Author

zipme commented Sep 7, 2023

hi @amannn

I also don't see any functionality from next-intl used in any relevant files

There is and it's in the middleware: https://codesandbox.io/p/sandbox/adoring-tu-8k2j6f?file=/middleware.ts:1,1

In your reproduction I don't get a full reload when I click on the "bar" link

The bar link works fine because the prefetch is set to true (which is also the default value of <Link />), however, from the /bar page and if you click on the home link, which has the prefetch={false} you can see the full page reload

@zipme
Copy link
Author

zipme commented Sep 7, 2023

@amannn And if I remove the middleware everything works normally, that's why I thought the culprit might be the middleware

@zipme
Copy link
Author

zipme commented Sep 7, 2023

My apology that I noticed that my initial description mentioned clicking on the 'bar' which has the correct behavior. I updated the description.

@amannn
Copy link
Owner

amannn commented Sep 7, 2023

Ah right, now I see. Here's a fix for your issue: vercel/next.js#43118 (comment)

@zipme
Copy link
Author

zipme commented Sep 7, 2023

@amannn OH NICE! It works like a charm! Thank you very much!

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