1

I have lambda in VPC and connect gateway to it. Also I add gateway url as second origin to cloudfront and create behaviour with /api/ path for this origin. But when I go to https://<cloudfront_url>/api/ I get {"message":"Not Found"} as response. But when I go to gateway url, I get Hello world as response.

My lamda code is a very simple "hello world" which i use to understand how lamda works:

exports.handler = async (event) => { const response = { statusCode: 200, body: JSON.stringify('Hello world') } return response 

}

My cloudfront configurations:

enter image description here enter image description here

Does anyone have any ideas about it?

5
  • Can you provide more details such as configuration or code? Commented Jul 15, 2020 at 13:29
  • 1
    @ChrisWilliams ofc. I updated my post Commented Jul 15, 2020 at 13:38
  • Does your API Gateway configuration have a resource for /api/? This configuration will try to access the API Gateway on this path not the root of Commented Jul 15, 2020 at 13:43
  • @ChrisWilliams. OMG. Thx a lot. It was my bad, I need to set /api* as path, not /api/. It's working now. Commented Jul 15, 2020 at 14:04
  • No problem added answer :) Commented Jul 15, 2020 at 14:06

2 Answers 2

1

This configuration for /api/* will be passing all requests to API Gateway still including the /api/ prefix on the request.

You need to make sure your requests account for this

Sign up to request clarification or add additional context in comments.

Comments

1

The only thing I need to do - change /api/* path to /api*

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.