0
votes

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

2

2 Answers

0
votes

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

0
votes

We can enforce the Content-Type header straight into the API Gateway like below. enter image description here

References can be found here: https://docs.aws.amazon.com/apigateway/latest/developerguide/request-response-data-mappings.html