By using AWS re:Post, you agree to the Terms of Use

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 3 months ago37 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"])
    }
answered 3 months ago
profile picture
EXPERT
reviewed 3 months 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