Reputation: 1
I have a cloud run NodeJS API which is running in cloud run and exposed publicly through Gcloud API gateway. The openAPI yaml spec is listed below.
OpenApi.yaml:
I am calling this API from a react client which passes the APIKey in authorization header. However, the browser pre-flight request failing with CORs issue. I have updated the API with proper cors and even tried with *. The API is working fine when I am removing the authentication from API gateway. The console error shows it is a 401 unauthenticated which means the Gateway is not authorizing the request. What I came to know that pre-flight request omits auth headers.Below listed the network tab error.
Network tab:
The console always shows cors error and 401 unauthenticated. Listed below the console error.
This API working fine from postman and also working fine if we remove authentication from API gateway. I have tried adding x-google-endpoints with allowCors: true as per the below stackoverflow link, still no luck.Also tried options section as per below link. answer
Upvotes: 0
Views: 89