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

Clicking back button after navigating with next/link causes page to download #50686

Closed
1 task done
timrae opened this issue Jun 2, 2023 · 6 comments
Closed
1 task done
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template.

Comments

@timrae
Copy link

timrae commented Jun 2, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP Fri Jan 27 02:56:13 UTC 2023
    Binaries:
      Node: 19.8.1
      npm: 9.5.1
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.4.5-canary.3
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 4.9.5

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue or a replay of the bug

https://github.com/timrae/nextjs-app-dir-reproduction

To Reproduce

  1. Start the web app (in prod)
  2. Click the 'Page 1' tab
  3. Click the 'Page 2' tab
  4. Click the browser back button

Describe the Bug

When running the reproduction case in production, the browser tries to download a file called 'page1' when you click the browser back button instead of going back to the page called page1. This doesn't happen in dev.

I'm using next/link with the Mui Tabs component, I'm not sure if this is relevant or not.
I'm also using a hidden nested route so that I can use a client-side root template.

Also not sure if this is related to #45595 or not.

Expected Behavior

Browser goes back to the previous page without trying to download anything

Which browser are you using? (if relevant)

Chrome 113.0.5672.127

How are you deploying your application? (if relevant)

Netlify

@timrae timrae added the bug Issue was opened via the bug report template. label Jun 2, 2023
@github-actions github-actions bot added the area: app App directory (appDir: true) label Jun 2, 2023
@timrae
Copy link
Author

timrae commented Jun 2, 2023

Here's a quick link to the problematic code: https://github.com/timrae/nextjs-app-dir-reproduction/blob/main/app/AppBar.tsx
It's running in production here if you just want to quickly see the behaviour: https://rad-bavarois-7ffe08.netlify.app/

@icyJoseph
Copy link
Contributor

icyJoseph commented Jun 2, 2023

@timrae For some reason, in your app, navigating between tabs, reloads the entire page:

Screen.Recording.2023-06-02.at.16.00.21.mov

As you can see at the end of the video, it is only when I disable the cache, that the page downloads. Obviously, a common user, with dev tools closed, has enabled cache so that happens to them.

The question is, why is your app not doing SPA navigation, rather it unloads, and I think that makes the browser save the .rsc format as the "the page", so that when you go back to it, it downloads the file.

Hopefully this is not a false lead into the issue 🤞 and can actually help us fix it.

@timrae
Copy link
Author

timrae commented Jun 2, 2023 via email

@icyJoseph
Copy link
Contributor

Could this be related? #49140 somehow the CDN is not serving the rsc file but the HTML one, and that breaks?

@timrae
Copy link
Author

timrae commented Jun 2, 2023

Thanks for your comments, I don't have enough understanding of next.js to say either way, but I tried deploying to Vercel instead of Netlify and it's working there so I'll close this issue for now :)

@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants