This is the setting that I thought would make it work, but no matter what I change I wasn’t able to get it working at all.
[[redirects]]
from = "/api/*"
to = '/.netlify/functions/servers/:splat'
status = 200
query = {path = ":path"} # apply this rule for /old-path?path=example
I’m also routing my calls through express and router() finishing it with
The redirect above only matches URLs with the query parameter in them.
I believe a second rule would fix this:
[[redirects]]
from = "/api/*"
to = '/.netlify/functions/servers/:splat'
status = 200
The same rule without the query parameter. Note, if there is more than one combination of query parameters, then each needs it’s own redirect. There is more about this in our documentation here. Quoting:
If you have multiple parameters, some of which are optional, this is the pattern to follow to ensure that we are prepared to handle all possibilities.
It also mentions putting the most general rules after the most specific.
Last but not least, I personally find the syntax of the _redirects file easier to work with. That is only my personal preference and it is definitely supported to define redirects in netlify.toml as well.
Would you try adding the redirect above? Also, please let us know if there are other questions.