Saturday, 28 January 2023

Redirect from a Python AWS Lambda with AWS Gateway API Proxy

Posting here because I just can't get a redirect working. Using AWS API Gateway linked to a Python Lambda function as a proxy just returns the response and header json. Here is the code

import json

def lambda_handler(event, context):
    response = {}
    response["statusCode"]=301
    response["headers"]=[{"key": 'Location',"value": 
     'https://www.google.com'}]
    data = {}
    response["body"]=json.dumps(data)
return response

Any help will be appreciated?

Thanks



from Redirect from a Python AWS Lambda with AWS Gateway API Proxy

No comments:

Post a Comment