Azure CDN [Microsoft CDN (classic)] does not honor 'preserve unmatched path: yes' in rules engines

211 Views Asked by At

I have an Azure CDN - Microsoft CDN (classic) that serves multiple single-page apps via different endpoints.

I am trying to add a backend API to one of the endpoints and would like to access it in SPA using /api route.

I have set up the origins like this:

origins screenshot

<my-endpoint>.azureedge.net perfectly loads frontend-spa (the default origin group).

I want to route:

<my-endpoint>.azureedge.net/api/resources/my-resource

to this (without /api/):

<my-backend-api>.azurewebsites.net/resources/resource

Here is the rule I have set up to do that:

rules screenshot

But the rule actually redirects to the home page of my backend:

<my-backend-api>.azurewebsites.net/

It discards anything after /api in the original route even though I have set Preserve unmatched path to Yes.

What have I missed in my rule/setup?

1

There are 1 best solutions below

0
hamenu On

Found the issue: as it turned out, we had another rule which would override the Preserve unmatched path of this one.

Didn't know that even if you override the origin, other rules are still applied to the request.

The other rule was like this:

URL path:
  not contains: <something>
URL rewrite:
  Source pattern: /
  Destination: /
  Preserve unmatched path: No

Updated to this:

URL path:
  not contains: <something>
  & not begin with: /api       <------------------------
URL rewrite:
  Source pattern: /
  Destination: /
  Preserve unmatched path: No