aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.43k stars 2.13k forks source link

API request doesn't have geolocation headers #7327

Closed mybluedog24 closed 3 years ago

mybluedog24 commented 3 years ago

Describe the bug CloudFront now has additional geolocation headers, but the API call doesn't contain these headers: https://aws.amazon.com/about-aws/whats-new/2020/07/cloudfront-geolocation-headers/ Is there a way to get these additional geolocation headers?

Current headers are:


{
    "headers": {
        "Accept": "application/json, text/plain, */*",
        "Accept-Encoding": "gzip, deflate, br",
        "Accept-Language": "en-US,en;q=0.9",
        "cache-control": "no-cache",
        "CloudFront-Forwarded-Proto": "https",
        "CloudFront-Is-Desktop-Viewer": "true",
        "CloudFront-Is-Mobile-Viewer": "false",
        "CloudFront-Is-SmartTV-Viewer": "false",
        "CloudFront-Is-Tablet-Viewer": "false",
        "CloudFront-Viewer-Country": "CA",
        "content-type": "application/json; charset=UTF-8",
        "Host": "xxxxxxxxx.execute-api.ca-central-1.amazonaws.com",
        "origin": "http://localhost:8100",
        "pragma": "no-cache",
        "Referer": "http://localhost:8100/",
        "sec-fetch-dest": "empty",
        "sec-fetch-mode": "cors",
        "sec-fetch-site": "cross-site",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36",
        "Via": "2.0 xxxxxxxxxxxxxxxxxxxxxxx.cloudfront.net (CloudFront)",
        "X-Amz-Cf-Id": "xxxxxxxxxxxxxxxxxxxxxxxxx",
        "x-amz-date": "20201203T060801Z",
        "x-amz-security-token": "xxxxxxxxxxxxxxxxxxx",
        "X-Amzn-Trace-Id": "Root=xxxxxxxxxx",
        "X-Forwarded-For": "xxxxxxxxx",
        "X-Forwarded-Port": "443",
        "X-Forwarded-Proto": "https"
    }
}
amhinson commented 3 years ago

@mybluedog24 Could you provide some more information about your setup? The following info would be helpful:

stale[bot] commented 3 years ago

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

mybluedog24 commented 3 years ago

Sorry for the late reply. I found out that it's not an amplify issue. Amplify creates API Gateway with edge optimized, which only contains IP address and country code in header. To get additional geolocation headers I have to configure my own CloudFront on API Gateway instead of using the edge optimized.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.