Allow glob pattern 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
nitro v2.9.6
node v22.0.0
npm v10.5.1
Reproduction
Try to create a redirect or something for certain type of files
Describe the bug
So this is what I have in my config:
routeRules: {
'/somewhere.js': {
redirect: '/somewhere-else',
},
},
This works fine, when I visit "somewhere.js" I got redirected. But If I want it to make it global, like this:
routeRules: {
'/**.js': {
redirect: '/somewhere-else',
},
},
It simply doesn't work. What I tried: /**.js, /*.js, **.js, *.js, **/**.js. I also tried to add \ and \\ in front of the dot, but same results.
What kind of glob is used in the pattern? I didn't find in the docs information how to make custom routes for assets.
Additional context
No response
Logs
No response
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 by tracing how the routeRules configuration matches request paths in Nitro, using the single-file redirect example as the baseline. Reproduce the configuration with a wildcard JavaScript pattern and verify that matching paths redirect as expected, then add or update coverage for the supported glob syntax.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100