Ive followed instructions at https://cloud.google.com/functions/docs/writing/http#functions_http_cors-python
So my code has this at the end
# Set CORS headers for the preflight request
if request.method == 'OPTIONS':
# Allows GET requests from any origin with the Content-Type
# header and caches preflight response for an 3600s
headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET',
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Max-Age': '3600'
}
return ('', 204, headers)
# Set CORS headers for the main request
headers = {
'Content-Type':'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Content-Type',
}
# END CORS
return (res, 200, headers)
where res is JSON
from a simple node app, im calling via
this.http.post(payloadTarget.url, JSON.stringify(clone)).subscribe(res => {
console.log('request complete', res);
},
err => {
console.log('request failed', err);
});
im getting this error on console
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
when testing a POST or OPTIONS using Postman i dont see the error but i also dont see the HEADERS im supposed to
im sure its something simple but looking at others similar questions and answers cant find anything that points to my issue