0

I have a cloudfront distribution which I am using to manage directing traffic to different components of my application.

/* goes to an S3 bucket hosting my client

/api/* goes to an API gateway

However, it seems that the /api/ part is passed on to my API gateway function, so rather than CFront://api/action proxying to APIGateway://action, cloudfront is proxying APIGateway://api/action.

This results in my lambda not being triggered.

Is there a way to ignore the cloudfront path and not forward that to the origin?

David Alsh
  • 6,747
  • 6
  • 34
  • 60
  • path pattern* Excuse me, it's 3am here and I am seeing spirals – David Alsh Jul 20 '18 at 16:42
  • 1
    The question I've marked this as a duplicate of includes S3 origins rather than API Gateway, but the answer is the same regardless of origin. CloudFront can prepend a string to the path (the Origin Path setting, under Origins), but it cannot remove path components without help from Lambda@Edge, which uses Lambda functions to manipulate headers, the path, and/or the query string. – Michael - sqlbot Jul 21 '18 at 01:21
  • 1
    Or, you could simply deploy your API stage as `/api`, of course, so that API Gateway expects the same spurious string at the beginning. – Michael - sqlbot Jul 21 '18 at 01:22
  • I have chosen to preappend `/api` to my API Gateway, thanks – David Alsh Jul 21 '18 at 01:53

0 Answers0