A few weeks ago I learned how to configure a CORS request with Spring Boot, I found it very simple in accordance with the documentation, as I would like to do the same with Python's Django.
For those who do not know CORS is the following ...
Imagine the site called Alice has some data that Bob wants to access. This type of request traditionally would not be allowed in the same browser source policy. However, by supporting CORS requests, the Bob site can add some special response headers that allow the Alice site to access the data.
CORS support requires coordination between the server and the client. The article with the Link below shows how clients can cross-source requests and how servers can configure themselves to support CORS.
The problem that this documentation is with the generic configuration and has snippets of code that need to be completed, because it will change according to the specific context of each project.
For example, in this code snippet below you need to be configured but I do not know what I need to write here:
else {
// Otherwise, CORS is not supported by the browser.
xhr = null;
}
I believe that every Python CORS configuration should be the same for any simple project, and my project is simple, I just need to know how to get the settings according to the generic code snippet provided by the site.
I intend to use any of these:
-
Chrome 3 +
-
Firefox 3.5 +
-
Opera 12 +
-
Safari 4 +
My Python API will upload the server to 8080 port , and my Angular API will go up on 4200 port , now I just need to know what the configuration will look like.
Could you help me?