Query HTTP Request Headers When Using Function URLs?

0

Can I query HTTP request headers in a Lambda function when configured to use Function URL? If so, can you provide a Python snippet to do so? Thanks!

asked 2 years ago252 views
1 Answer
1
Accepted Answer

The HTTP request headers are available within the event object. For example, the following code should return the requesting browser's user agent:

import json

def lambda_handler(event, context):
    return {
        'statusCode': 200,
        'body': json.dumps(event["headers"]["user-agent"])
    }
Ed
answered 2 years ago
profile pictureAWS
EXPERT
reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions