I have a CloudFront distribution configured with multiple Origins, including an API Gateway deployment.
I'm trying to create a Behavior on CloudFront so that any requests received to a
/api/* path will be redirected to the API Gateway and what I did was to simply create a new Behavior with the path pattern as
/api/* and Origin as the API Gateway deployment I mentioned. This works, however any requests containing a query string in it, such as
/api/data?since=2020-01-01, will result in a request to API Gateway without the query string, i.e, what will reach API GW is simply
To solve this problem, I tried to set a Cache Policy of
Managed-CachingOptimized (or even
Managed-CachingDisabled) and an Origin Request Policy of
Managed-AllViewer, but then CloudFront started ignoring completely that Behavior and processing the next one in line, which happens to be a S3 bucket. Once the request is sent to the S3 bucket, I get a 404 back as there's no such key in there.
I also tried to use the "Legacy Cache settings", but the same problem is happening.
Is it possible at all to have this "proxy" implemented with CloudFront and API GW? If yes, how would I do that?