question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SSR + custom 404 page + middleware on 12.2 causes client-side navigations between deployments to display a 404

See original GitHub issue

Verify canary release

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

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000
Binaries:
  Node: 16.15.0
  npm: 8.5.5
  Yarn: 1.22.19
  pnpm: 7.0.0-rc.7
Relevant packages:
  next: 12.2.4-canary.0
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

Brave 1.41.100 Chromium: 103.0.5060.134 (Official Build) (arm64)

How are you deploying your application? (if relevant)

Vercel

Describe the Bug

Nextjs router is unable to properly perform client side navigations after a fresh deployment is published in projects that use SSR, custom 404 page, and with any middleware function. If a user loads a page, then a deployment happens, then the user attempts to navigate, they will be presented with the custom 404 page. Refreshing the page will correctly display the server rendered page they attempted to navigate to.

Expected Behavior

As in next@12.1.x, the router should perform a hard navigation to the target page with the latest deployment.

Link to reproduction

https://github.com/bryanrsmith/simple-app

To Reproduce

https://github.com/bryanrsmith/simple-app is a simple app with two pages that use SSR. Also note that a custom 404 page is defined, and the project has a middleware function that does nothing (immediately returns NextResponse.next()).

  1. Deploy this project to vercel.
  2. Load the site in a new browser tab, but do not click any links.
  3. Redeploy the project (either a trivial code change, or use the Vercel dashboard to redeploy).
  4. Return to the original browser tab without refreshing it.
  5. Click the link to the other page, and then click the link back to the home page.

Expected: The navigations should succeed. Actual: The custom 404 page is shown.

While viewing the errant 404 page, a hard refresh will successfully display the server rendered page.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:5
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bryanrsmithcommented, Jul 28, 2022

Confirmed. Thank you!

1reaction
ijjkcommented, Jul 28, 2022

Hi, this has been updated in v12.2.4-canary.6 of Next.js, please update and give it a try!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Create Custom 404 Error Page For WebCenter Sites ...
Information in this document applies to any platform. Goal. How to create a custom 404 error page for WebCenter Sites 12.2.1 Remote Satellite ......
Read more >
Blog - Next.js 13
Next.js 13 introduces layouts, React Server Components, and streaming in the app directory, as well as Turbopack, an improved image ...
Read more >
SSR Handling of 404 and 500 Errors - Quasar Framework
This is where we render the page with Vue and Vue Router. Things to be aware of. We'll discuss some architectural decisions that...
Read more >
How To Properly Serve 404 Errors on SPAs (with SEO in Mind)
Out of the box, 404 error pages in SPAs don't work properly, creating problems for SEO. Here we'll review the pros and cons...
Read more >
next - NPM Package Overview - Socket - Socket.dev
You can also do client-side page transitions using the next/router ... "/other") { // Have SSR render bad routes as a 404. window.location.href...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found