2

I'm trying to set up Azure function so that all requests are sent to the same function. The proxies.json file is extremely simple:

{
  "$schema": "http://json.schemastore.org/proxies",
  "proxies": {
    "Root URI to Redirector Trigger Function": {
      "matchCondition": {
        "route": "/{*path}",
        "methods": [
          "GET",
          "POST"
        ]
      },
      "backendUri": "http://%WEBSITE_HOSTNAME%/myfunc"
    }
  }
}

So far so good, but when a request is sent, the proxied requests ends up being processed by the proxy again - ending in an infinite loop.

How can I specify in my proxies to proxy all requests accept those to /myfunc resource?

Aleks G
  • 56,435
  • 29
  • 168
  • 265

2 Answers2

2

I finally solved the issue, although it's not very elegant. My proxies.json now looks like this:

{
  "$schema": "http://json.schemastore.org/proxies",
  "proxies": {
    "Root URI to Redirector Trigger Function": {
      "matchCondition": {
        "route": "/{path}",
        "methods": [
          "GET",
          "POST"
        ]
      },
      "backendUri": "http://%WEBSITE_HOSTNAME%/"
    }
  }
}

I also edited my function.json to have `"route": "/". Now all calls to anything other than root are proxied to my function. Calls to route end up going to the function directly (and need to be handled separately).

Aleks G
  • 56,435
  • 29
  • 168
  • 265
1

You configuration forces the redirection to apply to everything on the domain. When redirection occurs, /myfunc also gets re-directed.

You can: 1. Change the route of your proxies to something different, f.e. `/api/{*path}'. 2. Move your function to a different domain.

Nick
  • 4,787
  • 2
  • 18
  • 24