Nitro don't understand [<params>] in routeRules...
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Environment
Hello Nitro team :)
I'm using Nuxt 3.17.4
My nuxt.config.ts:
export default defineNuxtConfig({
nitro: {
routeRules: {
'admin/**': {
headers: {
'x-nitro-rule': 'admin/**'
}
},
'[slug]/**': {
headers: {
'x-nitro-rule': '[slug]/**'
}
}
}
}
})
Nuxt pages structure:
pages/
├── admin/
│ └── index.vue // route /admin
├── [slug]/
│ └── index.vue // route /[slug]
Reproduction
No reproduction
Describe the bug
✅ When I visit /admin route, the header x-nitro-rule with value admin/** is correctly added.
❌ But when I visit a /[slug] route like /hello, the header x-nitro-rule with value [slug]/** is not added.
It looks like Nitro’s route matching doesn’t support dynamic segments [slug] in routeRules headers.
Am I doing something wrong, or is it a bug?
Thanks for your help!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the routeRules in nuxt.config.ts and compare the pages/admin/index.vue and pages/[slug]/index.vue cases described in the issue. Reproduce requests to /admin and /hello, then trace Nitro's route matching; done when the dynamic route receives the configured x-nitro-rule header consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt, typescript
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100