I have a solution for HTTP API Gateway with ANY method.
If you use authorizer on ANY method, your authorizer will reject the OPTIONS request as it doesn't contain an Authorization/Bearer token.
Solution is simple:
Next to the ANY route, create OPTIONS route with the very same path and no authorizer, pointing to lambda function. Then in lambda, add
const headers = {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
"Cache-Control": "max-age=0, no-store, must-revalidate",
Pragma: "no-cache",
Expires: 0
};
data = {
multiValueHeaders: {},
isBase64Encoded: false,
statusCode: 200,
headers: headers,
body: ""
}
if (event.httpMethod == "OPTIONS") {
return context.done(undefined, data)
}
This worked for me.