Azure Function App proxy is removing the query string

311 views Asked by At

A simple, simple proxy redirect to our www subdomain is resulting in the query string being stripped off.

There is no reason for this.

Taken this URL.. https://mydomain.ok/whatever?foo=something

Should redirect to.. https://www.mydomain.ok/whatever?foo=something

Instead it currently redirects to.. https://www.mydomain.ok/whatever

Any help would be greatly appreciated. It's very hard to test this properly.

For the following, REDIRECT_TO_WEBSITE=www.domain.com

Here is the example configuration:

{
  "$schema": "http://json.schemastore.org/proxies",
  "proxies": {
    "api": {
      "matchCondition": {
        "route": "/api/{*path}"
      },
      "backendUri": "https://%WEBSITE_HOSTNAME%/api/{path}"
    },
    "rest": {
      "matchCondition": {
        "route": "{*rest}"
      },
      "responseOverrides": {
        "response.statusCode": "302",
        "response.headers.Location": "https://%REDIRECT_TO_WEBSITE%/{rest}",
      },
    }
  }
}
1

There are 1 answers

1
mmarlow On

Found the answer on another SO question: Azure Function Proxies Multiple Query parameters with the same name

You simply need to add the request.querystring to the backend.request.querystring:

"requestOverrides": {
    "backend.request.querystring": "request.querystring"
}

So, your config would be:

{
  "$schema": "http://json.schemastore.org/proxies",
  "proxies": {
    "api": {
      "matchCondition": {
        "route": "/api/{*path}"
      },
      "backendUri": "https://%WEBSITE_HOSTNAME%/api/{path}"
      "responseOverrides": {
        "backend.request.querystring": "request.querystring"
      },
    },
    "rest": {
      "matchCondition": {
        "route": "{*rest}"
      },
      "responseOverrides": {
        "response.statusCode": "302",
        "response.headers.Location": "https://%REDIRECT_TO_WEBSITE%/{rest}",
        "backend.request.querystring": "request.querystring"
      },
    }
  }
}

It's worth pointing out that according to a commenter on that thread: "...going forward with .NET 6.0 onwards function proxies aren't supported, use API Management service instead"