I have a React.js project in which I wanted to implement an address search and a photo search, I used the Places API from Google cloud to do such a search, I did all the procedures of creating a project, creating an API key to use and leaving without any restrictions, but even without any restrictions it gives a CORS error, I downloaded an extension on Google that disables CORS and I managed to do the tests and it works normally but if I enable CORS it blocks it.
const handleInputChange = (inputValue) => {
axios.get(`https://maps.googleapis.com/maps/api/place/autocomplete/json?input=${inputValue}&types=(cities)&key=MINHA-CHAVE-KEY`)
.then((response) => {
const { predictions } = response.data;
const options = predictions.map((prediction) => ({
value: prediction.description,
label: prediction.description,
}));
setOptions(options);
})
.catch((error) => {
console.log(error);
});
};
In the credentials tab in Google Cloud, I already put restrictions passing only the URL of my website, I already removed all the restrictions, I used the cores-anywhere library and nothing, it worked, can someone help me?