Changing Host in LambdaEdge for an Origin-Request is forbidden

35 views Asked by At

I have a very simple approach for a PoC:

export const handler = async (event, context, callback) => {
    const request = event.Records[0].cf.request;
    console.log(JSON.stringify(request))
    // change Origin --> forbidden
    request.headers.host[0].value = 'picsum.photos';
    
    // uri change only works
    request.uri = '/200/300';
    // query change works too
    request.querystring = 'test=querystring';
    
    callback(null, request);
};

I need to change the host to a dynamic target. Like A/B-Testing.

The documentation Lambda@Edge - Restrictions does not state, that the host is a read-only for Origin-Requests.

How can I solve this?

Changing only the URI and/or Query works fine and results in the correct origin request.

0

There are 0 answers