Supporting glob pattern exclusion in route rules #2413
Replies: 2 comments 7 replies
-
Hi. Instead of single routeRules:{
'api/auth/**': { proxy: false },
'api/**': { proxy: 'https://some-proxied-url/**' }
} Supporting regex and exclude patterns, while possible and a nice idea for this usecase, will add to generic compatibility and complexity of route rules (that needs to be integratable with cross deployment compatibility) so it is unlikely we add this syntax support. |
Beta Was this translation helpful? Give feedback.
-
@guibulator @TheAlexLichter @trc-mathieu +1 for this. I am also struggling with how to produce a v2 server api which 'falls back' to an original default implementation for unchanged endpoints. It's the sort of thing that should be easy but just does not seem to be possible in an elegant way. to fill out my e.g, say I have the following handler files...
the behaviour should be pretty obvious navigating to ... so I can nearly achieve this with nitro route handler rules...
OR Nuxt route handlers
But it doesn't work properly for http://mysite/api/v2/unstable which proxies back to the old version of the unstable handler.. this doesn't work...
and this also doesn't work
in short, when specifying proxy with globs, there is no way to exclude specific paths from the proxy. This works
but it's super ugly because I need to repeat the proxy for every handler that is not changed in V2. Is there any better way around this? |
Beta Was this translation helpful? Give feedback.
-
Hi, I have a use case where an api exists at
/api/auth/
and some other endpoints starting with exactly/api/...
.I would like to define an exclusion pattern to be able to proxy requests that are not
/api/auth
to somewhere else. I haven't found a way and maybe it's not even possible. I was wondering if you had any suggestions or thoughts on this.Here's the part where you deal with routeRules:
https://github.com/unjs/nitro/blob/aabdc9c5c78c011a212c754058160ed23391361d/src/runtime/route-rules.ts#L46-L62
Without exclusion support, I need to explicitly set all the routes as proxy.
Ideally, I would like something like this to be supported:
Right now, I need to do specify every route, which is really cumbersome
Thank you for any help on this!
Beta Was this translation helpful? Give feedback.
All reactions