I. What is cross domain
The process of requesting from one domain to another is called cross-domain. Browsers go from a web page in one domain to request a resource in another domain, and one of the domain names, ports, and protocols are not the same, the request is cross-domain. Cross-domain is actually a protection policy of the browser.
It's on the web page.ajaxupon request,will report:No ‘Access-Control-Allow-Origin' header is present on the requested 'This error.。
Second, how to solve the cross-domain problem
1. The process of cross-domain requests
So we just need to make the request header information consistent.
1, in the program code to add, my back-end with python's flask framework, so add this paragraph in the app object can be
from flask_cors import * #Add header fields allowed for cross-domain requests # Add the access-control-origin header field to this current flask core object app # All urls under / are allowed to be accessed by all origins CORS(app, resources={r"/*": {"origins": "*"}})
2, in the nginx server to modify the configuration of nginx, configuration file as follows:
summarize
This article on the Python flask framework cross-domain problem solving method is introduced to this article, more related flask cross-domain content, please search for my previous articles or continue to browse the following related articles I hope you will support me in the future more!