Reputation: 1339
I have an issue validating a request with a model when the user changes the content-type of the request in a serverless framework lambda-proxy integration As per AWS docs, we can not change too much when using lambda-proxy integration
For example, the passthrough behavior that explains what happens when a validation model does not match the request type, can not be used on lambda-proxy integration.
My problem: I want to reject all requests that are not JSON so they must be forced to use the model validation. But at the same time, I do not want to change the integration type from lambda-proxy to lambda.
What can I do to solve this issue?
BR
Upvotes: 0
Views: 497
Reputation: 9605
We can enforce the Content-Type header straight into the API Gateway like below.
References can be found here: https://docs.aws.amazon.com/apigateway/latest/developerguide/request-response-data-mappings.html
Upvotes: 1
Reputation: 1540
One thing you can do is inspect the headers in the event object to confirm that it is the type you expect and if not return an error: https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html
Upvotes: 1