0

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?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
  • Please do not format every other word and phrase as code; only format code as code. See [the FAQ](https://meta.stackoverflow.com/q/254990/215552) for when code formatting should be used. – Heretic Monkey Apr 11 '23 at 13:43

0 Answers0