0

We have a NextJS application deployed on S3 and Lambda@Edge, we need to grab the request url (i.e. the Cloudfront URL from where the request was initiated), but when reading the host from the headers, we only get the S3 Bucket url serving as origin.

In essence, this is what we need: someId.cloudfront.net, this is what we get: some-bucket.s3.region.amazonaws.com

What are some alternatives to obtain the cloudfront url on the nextjs api? Thank you!

1 Answers1

0

Similar to this accessing origin URL from AWS lambda@edge

you need to use viewer request function to add X-Forwarded-Host header to requests forwarded to the origin and than also to the origin request function

NSS
  • 223
  • 1
  • 7