AWS Api Gateway + Lambda + custom domain (Route53) Missing Authentication Token issue

Viewed 7172

I am aware that many similar questions have been posted and answered here but none of them is quite the same with what I am experiencing.

I have a Lambda function that handles incoming requests (GET and POST). I also set up an api gateway as public facing endpoint. Additionally, I set up custom domain following Set up Custom Domain Name for API Host Name

The testing call works in both of lambda and api gateway console. Everything also works using the invoke URL but not with the custom domain I've set up.

Here are some more details:

Invoke URL (Works) :

https://{api gateway id}.execute-api.us-west-2.amazonaws.com/prod/endpoint

Custom domain endpint (Doesn't work):

https://api.{my domain}.com/endpoint

Base Path Mapping:

/endpoint   endpoint:prod

All Method Auth:

Authorization None
API Key Not required

Route53:

A record as alias that points api.{my domain}.com to the cloudfront distribution domain name as alias target. 

I'd really appreciate if anyone knows what's going out here.

3 Answers

I had met the same question several years ago and solved it by removing the 'stage' name from the URL.

  1. the URL of gateway API seems like the following:
https://{id}.execute-api.{region}.amazonaws.com/{stage}/todos
  1. if you have routed a custom domain https://api.xxx.com to gateway API {apiName}:{stage}, it seems like the following:
https://api.xxx.com

path: /
target: {apiName}:{stage}
  1. Finally, the correct way to call it is to remove the stage name:
// **remove stage name!!!!**

// Right
https://api.xxx.com/todos

// Wrong
https://api.xxx.com/{stage}/todos
Related