How to configure Azure Static Web app rewrite rules to another URL?

I have a Blazor WASM app deployed to an Azure Static Web app. I’ve managed to find out how to handle SPA routing, but I can’t figure out how to rewrite requests to my API (hosted on an Azure Web app, but under a different url). My staticwebapp.config.json looks like this:

{
  "routes": [
    {
      "route": "/api/*",
      "rewrite": "https://backend.com/*"
    }
  ],
  "navigationFallback": {
    "rewrite": "index.html",
    "exclude": [ "/images/*.{png,jpg,gif}", "/css/*" ]
  }
}

But when I do that, I’m getting a 405 error (presumably because it’s trying to do https://frontend.url/api/somerequest, then endpoint is definitely taking POST requests), if I add another API in and try that, it then just return my index.html file.

Is it impossible to reroute to another URL? And if yes, what do I need to do differently?

Read more here: Source link