CORS policy: No Access-Control-Allow-Origin header is present on the requested source.

Alfy Reid 20 Reputation points
2023-11-02T13:44:36.43+00:00

Hi all,

I have produced two containers - on is deployed to a web app and makes calls to the other which is in an azure container registry.

The problem that I encounter: No access-Control-Allow-Origin header is present on the requested resource. I don't know what this is.

The container that my website is trying to access contains python code. for a quick fix I tried using the flask_cors library - this didn't work.

I have been suggested to acquire an SSL certificate? this does not seem like the solution to this problem as far as I am concerned, but I could easily be wrong.

I appreciate any input :)

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

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 22,706 Reputation points Moderator
    2023-11-06T09:53:50.29+00:00

    Alfy Reid Thanks for reaching here!

    It seems like you are encountering a CORS error while trying to access a container from your web app. CORS stands for Cross-Origin Resource Sharing, which is a security feature implemented by web browsers to prevent unauthorized access to resources on a different domain.

    The error message "No Access-Control-Allow-Origin header is present on the requested source" means that the server hosting the container is not allowing requests from your web app's domain.

    Acquiring an SSL certificate is not a solution to this problem. However, it is a good practice to use SSL to secure your web app's communication with the server.

    To fix the CORS error, you need to configure the server hosting the container to allow requests from your web app's domain. One way to do this is by setting the Access-Control-Allow-Origin header in the server's response.

    Since you mentioned that you tried using the flask_cors library and it didn't work, I suggest checking if the library is properly configured.

    If you still encounter the same error, you may need to check the server's configuration and make sure that it is properly configured to allow requests from your web app's domain.

    Refer to this doc link- https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-rest-api

    0 comments No comments

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.