The whitelist of browser applications set up by Baidu Map developer Center does not work when sending requests using axios

I want to use ide/webservice-geocoding-abroad" rel=" nofollow noreferrer "> reverse geocoding API of Baidu Map, so I sign up for Baidu account and set up an application, as shown below:

clipboard.png

when I use axios to request, I report a cross-domain error

axios.get("http://api.map.baidu.com/geocoder/v2/", {
    params: {
      ak: "", // 
      location: e.point.lat + "," + e.point.lng
    }
}).then(res => {
    console.log(res)
})

Cross-domain error:
Access to XMLHttpRequest at" http://api.map.baidu.com/geoc." from origin" http://test.lalei.com" has been blocked by CORS policy: No "Access-Control-Allow-Origin" header is present on the requested resource.

for security reasons, ak didn"t write it out, ha

Dec.29,2021

use jsonp


Hello. To borrow what you said upstairs, you can refer to the questions you have answered before, which should be able to solve your problem. https://codeshelper.com/q/10.

Menu