terence55 / react-baidu-maps

React Components for Baidu Maps
24 stars 4 forks source link

Baidu Maps Gives CORS error with upgraded react version(16.7.0) #9

Closed bawaji94 closed 5 years ago

bawaji94 commented 5 years ago

I was trying to use baidu maps in my project and with react version 16.7.0 and it would give an error

Access to fetch at 'http://api.map.baidu.com/getscript?v=2.0&ak=...' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

and the maps does not render.

However, when I downgrade the react version to 15.4.2, there is no such error and the map renders perfectly.

terence55 commented 5 years ago

I upgrade my sample project to Webpack 4 and React 16, and there is no the same problem.

Could you check this issue if it's the same problem? It was caused by a browser plugin. https://github.com/terence55/react-baidu-maps/issues/4

if it's not the same problem, please provide a reproducible demo in codesandbox or codepen.