1

Using AWS Cloudfront's Lambda@edge capability, I want to pass some string generated on the Client Request through to the Client Response. Preferably without modifying the source at the server.

I notice that the ID AWS utilizes, x-amz-cf-id, is in the headers for the response on my browser, and is added by AWS before the Origin Request to identify that individual request.

So it would seem on the surface that this data could be passed via header, but setting a custom-named header does not appear to make it back to the browser. I used:

request.headers['x-pass-test'] = [{key: "x-pass-test", value:"theTestValue"}];

Any ideas, or is this a known limitation?

Clarification

The short version is, is there a way to get data from the Client Request lambda to the Client Response lambda?

Randy Hall
  • 7,716
  • 16
  • 73
  • 151
  • Not really a limitation... You are drawing a false equivalence. `request.headers` are sent to the origin, not the browser, and `X-Amz-Cf-Id` as mentioned at your link is not the same value as what the browser sees -- there is a request header and a response header of this same name, and the value differs on the front side of the cache and the back side. You are wanting to echo something back to the client that the client generates? Or that a request trigger generates? If the latter, then is it s viewer-request trigger or origin-request? – Michael - sqlbot Mar 13 '19 at 23:49
  • Is this essentially the same question as https://stackoverflow.com/q/55128624/1695906? – Michael - sqlbot Mar 13 '19 at 23:53
  • @Michael-sqlbot it's the same problem, but a different approach. The other question is trying to set a cookie on the request that the user will receive in the response. This question is trying to pass some data between the client request lambda and the client response lambda... ultimately to achieve the same goal not shown here, but the questions are about two different things. – Randy Hall Mar 13 '19 at 23:56

0 Answers0