NuxtN
Nuxt5mo ago
17 replies
lazygopher

Config cache using routeRules without effecting inner paths

I'm trying to cache responses on the client with max-age 30 and stale-while-revalidate 30.
The endpoint is /api/featureA/<id>.
The UI page that makes the request for this endpoint also makes additional api calls to /api/featureA/<id>/something?param=value.

How can I config routeRules that catches only /api/featureA/<id> but not handling the inner one?
I tried settings something like this but then nuxt returns 404 for the inner request

export default defineNuxtConfig({
  routeRules: {
    "/api/featureA/*": { swr: 30 },
  }
})
Was this page helpful?