vercel / vercel/next.js

getStaticProps not triggered on browser back button when rewrites are used and middleware exists

Open
#82,829 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Middleware
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/boreens/nextjs-rewrites

To Reproduce
  1. Got to https://nextjs-rewrites-ten.vercel.app/hunder
  2. Click on any link and then click back

https://github.com/user-attachments/assets/8c33a796-f886-4169-a965-ede3027bbe2e

Current vs. Expected behavior

When rewrites are set up in config, next link is used for navigation and middleware exist on browser back button click getStaticProps is not triggered. When middleware is deleted everything works as expected.

https://nextjs-rewrites-git-without-middleware-try-dig.vercel.app/hunder

Provide environment information
Hosted in Vercel
Which area(s) are affected? (Select all that apply)

Middleware

Which stage(s) are affected? (Select all that apply)

Vercel (Deployed)

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction repository at https://github.com/boreens/nextjs-rewrites and compare the deployed middleware and no-middleware URLs. Reproduce the browser back-button flow from /hunder, then inspect why getStaticProps is not triggered when rewrites, next/link navigation, and middleware are combined; done means the expected trigger occurs with middleware enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.