Open johangirod opened 6 years ago
I am having this same issue. I'd like serve to rewrite all routes to a single page except a specific route (or sub-routes). Is there any way to accomplish this?
For anyone else finding this issue - I had some success for my use case for making apple-app-site-association accessible (rewrites all routes for a react page using serve-handler, except for specified routes):
{
rewrites: [
{
source: "/**!(apple-app-site-association)", destination: "/index.html"
},
{
source: "/**/**", destination: "/index.html"
},
{
source: "/apple-app-site-association",
destination: "/apple-app-site-association.json"
},
]
}
Hope this helps someone!
shameless self-promotion alert:
this feature is available in my @warren-bank/serve
fork of serve
both redirects and rewrites support an optional boolean terminal
attribute, which will prevent any additional rules from being processed.
something else to bear in mind:
--single
cli option in this fork is handled differently
serve
prepends a redirect that matches all request paths and redirects them to '/index.html'
In a SPA settings, I'm prerendering the some landing pages for SEO and perf. But I can't figure out the corresponding rewrites rules.
So far, I've tried:
This doesn't work because apparently, all the rewrites rules are applied to the path (instead of stopping after the first match).
The problem is that I can't seem to find a way to negate the two prerendered path in the last rule, using minimatch.
What would be the proper way to handle this use case ? Is it even possible ?
Thanks!