How to forward access-control-allow-origin header from a Web App to a Front Door?

Fazenda 1 Reputation point
2021-02-11T11:38:00.12+00:00

I currently have a web app running in containers with the access-control-allow-origin header correctly configured on it. However, when I check the front door in front of this web app, the same header has the option '*' -- accepting all types of requests, differently from the configured one.

How do I get the front door to propagate this web app header?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,933 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 19,151 Reputation points Moderator
    2021-02-23T00:58:22.283+00:00

    Hi @Fazenda

    We apologies for the delay in response.

    Based on the docs: "CORS on Azure Front Door will work automatically with no extra configuration when the Access-Control-Allow-Origin header is set to wildcard (*) or a single origin. Azure Front Door will cache the first response and ensuing requests will use the same header.

    If requests have already been made to the Azure Front Door before CORS being set on your origin, you'll need to purge content on your endpoint content to reload the content with the Access-Control-Allow-Origin header."

    Keep in mind that you can create a rule in the Azure Front Door Rules Set to check the Origin header on the request. If it's a valid origin, your rule will set the Access-Control-Allow-Origin header with the correct value. In this case, the Access-Control-Allow-Origin header from the file's origin server is ignored and the AFD's rules engine completely manages the allowed CORS origins.

    Please read this doc for more details. Let us know if you have further questions.

    Thanks,
    Grace

    70884-cross-origin-resource-afd.png

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.