1. I have configured it according to the CORS help document. The document path is: http://www.ruanyifeng.com/blo...;
Local project configuration is as shown in the figure: (1). Import support package
(2) Configuration of web.xml
2. Through the above configuration, in theory it is possible to make cross-domain requests, but in fact it is not possible! Paste my html code:
axios - get example
axios.get
The url is Douban's api
The running result is:
The request header and the request status are:
(1)General
(2)Response
(3)Request
3. I am very confused. The request status code is 200, why is there no The data is returned and the console reports an error? The official document says that as long as it is configured, it can be used across domains. Why can't it be implemented on this machine? Is there something wrong with the configuration? Or is there something missing? Please give me some advice from relevant experts! I am a member of the Third Party of China. I urgently need to solve this problem when I am working on a project. Thank you very much!
There are many ways to solve cross-domain requests. The cors method relies on the server to return the correct response header information
Access-Control-Allow-Origin
. Your screenshot shows that the Douban api does not returnAccess-Control-Allow-Origin:*
, so cross-domain failure.You can also use jsonp to solve cross-domain problems. Douban supports jsonp.