I'm getting this error in the browser after loading the map component in a url routed component. Error says; Access to fetch at 'https://maps.googleapis.com/maps/api/place/js/PlaceService.QueryPlaces?1m6&1m2&1d41.90022359631215&2d-87.64533764326575&2m2&1d41.91612886759679&2d-87.61957100236418&2sen-US&4ssri%20lanka&29e3&36m1&2e1&1032e0&callback=_xdc_._1y2syl&key=AIzaSyCFEwhxO-1BrHiDjuv8IKaiDUj9arIg_fo&token=64950' 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.
Getting Help
Before doing this, did you:
- Read the documentation
- Read the source code
You can get someone's help in three ways:
- Ask on StackOverflow with a google-maps tag or use react-google-maps as a keyword
- Ask in the chat room
- Create a Pull Request with your solutions to your problem
Please, be noted, no one, I mean, no one, is obligated to help you in ANY means. Your time is valuable, so does our contributors. Don't waste our time posting questions like “how do I do X with React-Google-Maps” and “my code doesn't work”. This is not the primary purpose of the issue tracker. Don't abuse.
You need to setup your google API key at https://console.developers.google.com/apis/credentials/
Issue was figured out. I had setup default 'None' restrictions means contains http obviously. Issue was I had set url header as http://localhost:3000/create-professional-account with react-router-dom. I removed '-' (hyphens) in header then it worked as in http://localhost:3000/ . I think Google-maps back-end got issues reading that.
but today it stopped working. I really need help with that. If I refine the issue again; Places search box works in localhost:3000 but not in localhost:3000/create. routes are defined using react-router-dom.
Try to install the Allow-Control-Allow-Origin: * extension from chrome and turn it on. Works for me when I have that issue.
I had a similar issue with google maps street view api. It was loading some of the images while not loading some them. I cleared all restrictions and the api key is unrestricted now. And it works.