5
votes

I am currently building a rest api, for this I am using Google Cloud API Gateway and Google Cloud Run. I've been looking at all the google cloud documentation and researching elsewhere and I can't find how to add a custom domain to an API gateway instance. The funny thing is that there is more documentation for Google Cloud endpoints, I could find how to do it with endpoints but it does not apply to my use case.

I have 10 instances of google cloud run each one running a microservice respectively and I want to join everything in a single domain and add support with openapi, but I have failed in the attempt.

In any case, if someone has managed to customize the domain of an api gateway instance, I would appreciate if you could guide me, greetings.

1
Have you had any CORS errors? I am getting this error: "Access to fetch at curl my-gateway-a12bcd345e67f89g0h.uc.gateway.dev/hello?key=example' from origin 'example.netlify.app' 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled." Maybe both of our experiences stem from a lack of customization?ElektrikSpark
@ElektrikSpark Maybe this has to do with netlify, but this would be a problem for another question. Returning apparently for now it is not possible to enable a custom domain for the gateway api.Feloo
I am thinking that there may be a need to set up CORS headers in the OpenApi config. Is this something that you have explored? Anyway, it is my understanding that there is currently no way to customize the domain name, maybe this will be an option when the service leaves beta.ElektrikSpark

1 Answers

4
votes

For the beta release, custom domain names are not supported on GCP for API Gateway. Since it is still beta as of today, if you want to use a custom domain, you could use Cloud Endpoints in Cloud Run or you could even look into using Microservices in App Engine.