This article mainly introduces the solution: No’Access-Control-Allow-Origin’ cross-domain, the article introduces it in detail through the sample code, and has a certain reference learning value for everyone’s study or work. Friends who need it will follow Let’s study together with the editor
This is a common cross-domain request problem, which is common in projects where the front and back ends are separated. The request path in the front-end project directly uses the back-end request path (for example: http://192.168.1.1:8080/demo/getUser.do), but According to the browser’s network request rules, the background server is not allowed to call directly in this way (it will be intercepted by malicious hackers). As a result, the cross-domain request was rejected (as shown below).
Access to XMLHttpRequest at’http://192.168.1.1:8080/app/easypoi/importExcelFile’ from origin’http://localhost:8080′ has been blocked by CORS policy: No’Access-Control-Allow-Origin’ header is present on the requested resource.
Many on the Internet allow to modify the configuration files in various projects, but it is not easy to use. In fact: only need to modify a filtering configuration of the background server (such as java’s tomcat) to allow cross-domain requests;
Add the following configuration filter to the conf/web.xml configuration file of the requested server (tomcat)
(For example, when there are multiple filters in web.xml, put the following configuration at the forefront)
In this way, cross-domain requests are allowed on the root (back-end), and there are also malicious injections by hackers that cause the server to be paralyzed (except for the intranet or stand-alone version).
- (Windows+xrdp+ubuntu16.04) Remote server error: “password failed error-problem connecting”
- Request cannot get static resource
- Struts2 is cracked, a serious loophole, a perfect solution
- Exception of browser accessing servlet404
- Error creating bean with name ‘xxcontroller’
- Wireshark filtering HTTP packets
- How to Use the object of ES6 to clear the object value
- soapUI Error Loading WSDL
- Flask Request an extension before_request after_request errorhandler
- A child container failed during start
- Basic use of filter
- Principles of jsons and Corp
- Ambiguous reference to member ‘dataTask(with:completionHandler:)’
- Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar (default) on project
- Solve the problem of flag error valueerror: View function did not return a response
- [C + +] C + + overload operator = must be a nonstatic member function?
- Configure HTTPS and self signed certificate for nginx
- HTTP 400 error – bad request
- Springboot integration redis reports non null key required (solved)