I have a question about API Gateway authorizers and lambda functions.
My scenario is the following: I have a resource in AWS API Gateway for which the authorization is enabled. The authorizer calls a lambda function which, if the user is not authorized, redirects the user to another URL.
So basically I would like to customize the authorizer to return a 302 rather than a 401/403/500 status code. Do you know if that is possible?
I know that having a lambda function in the integration phase of the gateway lets me customize the response. What about this particular scenario?
Thanks.
You cannot change status code or headers through Lambda Authorizer, but you can do it through Gateway Responses.
UNAUTHORIZED
)You can now redefine the response status, headers and body as you like.
Full documentation: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-gateway-response-using-the-console.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With