If you are having a 403 Forbidden error from CloudFront, that means your domain name is not linked to your CloudFront distribution and because CloudFront stays in front of your API GATEWAY you need to create a CNAME record pointing your domain name to your CloudFront target domain name in order for it to work.
So, If you need to point your api to a custom domain name, all you have to do is following those 2 easy steps:
1 - CREATING YOUR CUSTOM DOMAIN NAME
Go to the API GATEWAY console and click on the Custom Domain Name menu. Click on the Create Custom Domain Name button. Next, assign a certificate matching the same domain name you are creating and map to the root path and destination of your desired api. Lastly, copy the CloudFront Target Domain Name. You will need to paste that in your Route 53 record.
2 - CREATING A CNAME RECORD ON ROUTE 53
Create a CNAME record on Route 53 for the same custom domain name, assigning to it the CloudFront Target Domain.
And thats it! Your API GATEWAY will now respond to your custom domain name.
Comments
Post a Comment