1
votes

Is there a way to enable Cors in the Google Api gateway config for Cloud Run services?

I enabled Cors in the service themselves, but I always get

Access to XMLHttpRequest at 'xxx' from origin 'http://localhost:4200/' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Wondering if the Api Gateway is the problem, because calling the cloud run service directly works fine.

1
This is a highly voted feature, it's not available yet. groups.google.com/g/api-gateway-users/c/9CwyQr1c420Pentium10

1 Answers

2
votes

You could overcome the missing functionality

  • by adding a load balancer
  • create a custom header Guide

You just need to add the "Access-Control-Origin" header:

Allow all

Access-Control-Origin:'*'

See steps for API Gateway and Load balancer.