Azure functions proxies Invalid URI: noSlash

843 Views Asked by At

I am trying to use an Azure function proxy to allow CORS on an API which I don't have access to the server for.

I have followed the steps in this article

I have the route template as /qless/{*rest} and the backend URL as https://merchant.us1.qless.com/qless/api/v1/{rest} however the response I recieve is: 400 (Invalid URI: noSlash).

If I change to use the Github API (as they do in the article), it works fine.

I have ensured that localhost (where I am sending request from) is listed in the functions' CORS settings.

The full request that I send is: https://XXXXXXXXX.azurewebsites.net/qless/kiosk/location/XXXXXXXX/queues/ so I don't see where the additional slash is coming from (like the response suggests). I have tried removing trailing and intermediate slashes. Thanks for your assistance.

Edit

By sending a Proxy-Trace-Enabled header I have realised that the function is rewriting / as %2F - how can I prevent this?

      {
        "source": "rewrite-uri",
        "timestamp": "2020-02-27T05:04:28.8777839Z",
        "elapsed": "00:00:00.2596935",
        "data": {
          "message": "Updated request URL per specified rewrite template.",
          "request": {
            "url": "https://merchant.us1.qless.com/qless/api/v1/kiosk%2Flocations%2FXXXXXXXXXX/"
          }
        }
      }
1

There are 1 best solutions below

0
TomHill On

Found the solution in this issue

Set AZURE_FUNCTION_PROXY_BACKEND_URL_DECODE_SLASHES as an application setting to true (defaults to false) which is documented here