I'm trying to make a GET request to a GCP Cloud Function from the frontend in JS, but I am getting the error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://us-central1-<project>.cloudfunctions.net/<function-name>. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
I was originally going to call a 3rd party API from the front end but it gave me this error too, then I was going to see if I could use a CF as a middleman, but I'm guessing I'll need to set up a server?
Surely its possible to make a GET request from the frontend to a cloud function or other site?
axios({
method: 'GET', //you can set what request you want to be
url: "http://<cloud-function>.com/<function-name>",
data: {message: "test"},
}).then(data => {
console.log(data)
}).catch(error => {
console.log(error)
})