I created a lambda function with a API gateway and Cloudfront distribution in the front
in the cloudfront behaviors I disabled caching

this is the lambda function:
exports.handler = async (event) => {
const response = {
statusCode: 200,
body: JSON.stringify('rawQueryString is: ' + event.rawQueryString),
};
return response;
};
calling the api gateway I see the querystring in the lambda response https://xxx.execute-api.us-east-1.amazonaws.com/api?name=john
rawQueryString is: '?name=john'
calling the cloudfront distribution i can't see the querystring in the lambda response https://xxx.cloudfront.net/api?name=john
rawQueryString is: ''
I tried with "Origin Request Policy"

but now when i call https://xxx.cloudfront.net/api?name=john
I get
{
"message": "Forbidden"
}
You should setup origin request policies for your cache behavior. You can try with AWS managed Managed-AllViewer policy or create new one just to forward the query strings:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With