0
votes

I've configured CloudFront to S3 with a static page and the second behavior on API Gateway with a simple API. The static page works fine but I have a problem with API Gateway because when I try to send a request to API then I got an error 'missing authentication token'. I've configured allowed headers but still, I get this error. API Gateway connects with AWS lambda.

I want to have on / simple static page but on /somePath path API which handles a request from static page.

Have you some ideas about what exactly can be wrong?

1
Are you able to hit the API endpoint directly without any issues? Missing Authentication Token is also an indication that the URL being used to invoke the API is not in the right format.Suraj Bhatia
Yes I do. API gateway works fine but I tried to used proxy on API gateway and currently I got a 502 error. I tired to setup with mock but still it doesn’t work..Matrix12
For the 502, did you check API Gateway execution logs? That will give you a more specific error messageSuraj Bhatia
502 is was bad configured API Gateway but I found the reason..I did the exercise and I redirect CloudFront to API Gateway without S3 and on the default path (in cache behavior section) and API Gateway works correctly, but when I tried to set S3 on default path and API Gateway on /api path I got a error "Missing Authentication Token".Matrix12

1 Answers

-2
votes

In your API Gateway Resources page, is "API Key Required" set to true for the endpoints you are trying to hit? To check, go to the "Resources" page, select the endpoint you are checking by clicking on the method (ie. GET), then clicking "Method Request". If it is, you need to pass in x-api-key in the header.