So I've researched the web and tried almost all the solutions on their for this issue I am having with CORs using yelps fusion API. I'm using react but trying to call this API with axios. Here is my code.
static YelpApiSearch(searchedCity, onSuccess, onError) {
const config = {
Authorization: process.env.REACT_APP_KEY
Origin: "https://vendors.test"
};
axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
axios
.get(`https://corsanywhere.herokuapp.com/https://api.yelp.com/v3/businesses/search?categories=foodtrucks&location=${searchedCity}`,
{
withCredentials: true,
headers: config
}
)
.then(onSuccess)
.catch(onError); }
Refused to set unsafe header origin error
Any help would be appreciated. Thanks!
Authorization: process.env.REACT_APP_KEY— That looks like something which is supposed to be a secret shared only by you and Yelp. Do you really want to give it to Corsanywhere and every user of your app so they can make calls to Yelp using your access rights?