0

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 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.