- Newest
- Most votes
- Most comments
The error you're experiencing with your API Gateway is related to CORS preflight requests failing with a 500 error instead of returning a 200 status code. This "unable to transform request" error in CloudWatch logs suggests there's an issue with how your API Gateway is handling the OPTIONS preflight request.
Here are some steps to troubleshoot and fix this issue:
- For CORS preflight requests, you need to ensure that the OPTIONS method is properly configured:
- Verify that the OPTIONS method has no authorizer attached to it (while your other methods can have JWT or other authorization)
- Make sure the OPTIONS method returns the necessary CORS headers in its response
- For binary content handling with multipart/form-data:
- Check that your binary media types configuration includes both '/' and 'multipart/form-data' as you mentioned
- The "unable to transform request" error often occurs when API Gateway can't properly process the request payload format
- For your mapping templates:
- Ensure they're correctly configured for handling binary data
- For the OPTIONS method specifically, consider using a mock integration instead of forwarding to Lambda, which returns a simple 200 response with the appropriate CORS headers:
{
"statusCode": 200,
"headers": {
"Access-Control-Allow-Headers": "Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "OPTIONS,GET,PUT,POST,DELETE"
}
}
- After making these changes, redeploy your API to ensure the changes take effect.
Remember that CORS is a browser security feature, which is why testing with tools like Postman might work while browser requests fail. The preflight OPTIONS request must be handled correctly with appropriate headers for the browser to proceed with the actual request.
Sources
CORS error while accessing an endpoint in API gateway | AWS re:Post
CORS Preflight fails on HTTP API Gateway | AWS re:Post
answered a year ago
Postman doesn't send headers unless you add them
Add a Origin Header on the request in PostMan and set it to the Domain you are accessing. Also if your in Proxy mode, your APi back end needs to send the Correct headers back also as APi Gateway will not inject them
Relevant content
asked 2 years ago
asked 2 years ago
- AWS OFFICIALUpdated a year ago

It is working on the test within the API Gateway but not working in the postman