User Domain for API Gateway Returning 403

I am creating api using Gateway and Lambda APIs. Using the URL specified in the Stage Gateway API editor, everything works fine; however, when I try to go to a custom domain, I encounter some problems.

The first thing I tried was to use the CNAME record in Route 53 directly from my domain to the domain that I received from the API gateway. This returned some errors, and I think the wrong decision is right?

Next, I tried the Custom Domain Names function in the Gateway API. My understanding is that this will minimize the CloudFront distribution, which I can then go from route 53. When I created the custom domain and added the domain mapping, it provided me with the URL to what I assume is the CloudFront distribution. The link returns a 403 response, and there was no distribution in CloudFront. What is a good way to debug this problem?

+6
source share
4 answers

Here is the developer's guide if you have not seen it. http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html

All you have to do is install CNAME with your DNS provider pointing to the CF distribution that the Gateway API provides you with. You cannot directly access the CF distribution APIs. The API gateway maps the API / stage to the base loop that you configured in the API, so only API calls directed to the domain name will work.

+7
source

You need to use the node header in the request. The host must be your custom domain.

curl https://<cf-id>.cloudfront.net/myapi -H "Host: api.myapi.com" 
+3
source

In my case, I had to add a base path mapping.

+1
source

Related problem:

Exactly below the answer:

 {"message":"Forbidden"} 

in browser

 F12 > Network > ( select error line) > Response (on right side) 

may mean that something is wrong in the url

0
source

All Articles