nitro icon indicating copy to clipboard operation
nitro copied to clipboard

[Vercel] ISR caching ignores route parameters in dynamic routes

Open fmoessle opened this issue 2 weeks ago • 6 comments

Environment

Nuxt version: 4.2.1 Vue version: 3.5.25 Nitro version: 2.12.9 Platform: Vercel ISR: Enabled

Reproduction

Repository: https://github.com/fmoessle/nitro-vercel-isr Live demo: https://nitro-vercel-isr.vercel.app/

Describe the bug

When using ISR (Incremental Static Regeneration) with Nitro on Vercel, dynamic routes return cached content from the first visited route and redirect the URL back to that first route.

export default defineNuxtConfig({
  compatibilityDate: '2025-07-15',
  devtools: { enabled: true },
  routeRules: {
    '/**': {
      isr: { allowQuery: [] }
    }
  }
})

Steps to Reproduce

Visit / (or any route like /hello) - page is correctly cached Visit a different route like /goodbye The page shows content from step 1 AND the URL changes back to the first visited route

Expected Behavior Each dynamic route should:

Generate and cache its own content based on the route parameter Maintain the correct URL in the browser Not redirect to previously cached routes

Actual Behavior

All routes return the same cached content from the first visited route The browser URL is changed/redirected back to the first cached route Subsequent route visits are essentially ignored by the cache mechanism

Additional context

No response

Logs


fmoessle avatar Dec 08 '25 13:12 fmoessle

After digging a bit deeper, I think I've found the root cause: No matter which route I visit, the cache key is always exactly the same. That's why Vercel always returns the same response. This behavior currently only occurs with Vercel ISR in combination with allowQuery: [].

visit "/" visit "/test"
Image Image

The last working version of nitropack seems to be this one:

"pnpm": {
  "overrides": {
    "nitropack": "2.12.4"
  }
}

fmoessle avatar Dec 10 '25 08:12 fmoessle

Can you try latest nitropack nightly? (this issue seems not affecting new allowQuery/passQuery usage)

pi0 avatar Dec 10 '25 09:12 pi0

Here is the deployed version with

  "overrides": {
    "nitropack": "npm:nitropack-nightly@latest"
  }

Repo: https://github.com/fmoessle/nitro-vercel-isr/tree/nightly-test Live: https://nitro-vercel-isr-git-nightly-test-auenland.vercel.app

Issue still occures.

fmoessle avatar Dec 10 '25 09:12 fmoessle

Try this: (make sure to cleanup old/other fields and dependencies and lockfile)

{
  "name": "nitro-vercel-isr",
  "type": "module",
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "dependencies": {
    "nuxt": "4.2.1",
    "vue": "3.5.25",
    "vue-router": "4.6.3"
  },
  "resolutions": {
    "nitropack": "npm:[email protected]"
  },
  "packageManager": "[email protected]"
}

(Demo: https://nitro-vercel-1dqsgwzny-pi0-team.vercel.app/test/ (also updated to log {{ route.params.slug }})

pi0 avatar Dec 10 '25 11:12 pi0

I was unable to open the demo (access required) but updated mine: https://nitro-vercel-isr-git-nightly-test-auenland.vercel.app/

I can confirm that there is now an additional cache key and caching works as expected.

Image

Thank you so much Pooya, I hope my reproduction helped (still wondering why no one else experienced this issue 🤷).

Will 2.13.0 be released soon?

fmoessle avatar Dec 10 '25 11:12 fmoessle

Awesome! Yes hopefully soon, in the meanwhile pinning nightly version is almost identical to 2.13 release

pi0 avatar Dec 10 '25 12:12 pi0