amplify-hosting icon indicating copy to clipboard operation
amplify-hosting copied to clipboard

Browser user-agent not available in AWS Amplify

Open p00000001 opened this issue 2 years ago • 23 comments

Before opening, please confirm:

  • [X] I have checked to see if my question is addressed in the FAQ.
  • [X] I have searched for duplicate or closed issues.
  • [X] I have read the guide for submitting bug reports.
  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • [X] I have removed any sensitive information from my code snippets and submission.

App Id

d3qizoh4juhaxq

AWS Region

eu-west-2

Amplify Hosting feature

Frontend builds

Frontend framework

Next.js

Next.js version

13.4.16

Next.js router

App Router

Describe the bug

The request user-agent header always has a fixed value of Amazon Cloudfront when read in AWS Amplify apps.

Like many apps, we rely on the user-agent header to customize the response and for statistical logging.

Expected behavior

There appears to be no way to access the user's user-agent data from AWS Amplify. Either of the following solutions would be okay:

  1. An option to keep the original browser user-agent header and not replace it with Amazon Cloudfront
  2. Copy the original browser user-agent header into a new custom request header e.g. origin-user-agent that is accessible in AWS Amplify

Without access to user agent information, we cannot use AWS Amplify to host our app.

Reproduction steps

  1. Make a request to an AWS Amplify app from a browser
  2. Read the user-agent request header from the app

Build Settings

No response

Log output

# Put your logs below this line


Additional information

No response

p00000001 avatar Aug 18 '23 11:08 p00000001

This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!

github-actions[bot] avatar Aug 22 '23 06:08 github-actions[bot]

@Jay2113 are you able to give any indication whether there are any plans to implement access to the original user-agent or similar in the near-future on Amplify? Looking further, I see other people have raised similar issues over the past couple of years but there has been no indication if this is even on the road map. We can't deploy to Amplify without access to the user agent, so I would be grateful to understand is there are plans to support this? Many thanks.

p00000001 avatar Sep 13 '23 09:09 p00000001

Related unresolved issues due to user agent missing #1992 #1993 #2459 #2800 #3202 #3322

p00000001 avatar Sep 13 '23 09:09 p00000001

bump

hunganhAtWhill avatar Nov 10 '23 12:11 hunganhAtWhill

Any news on this, please? we're about to migrate to Amplify and this seems to be an obstacle for us to move, is there any ETA please? or some workaround for now?

@Jay2113 any tips/tricks here please?

belyas avatar Nov 14 '23 17:11 belyas

Same issue here.

ysfbsf avatar Nov 14 '23 18:11 ysfbsf

Same issue, seems AWS amplify team has selective blindness.

Jyy10 avatar Feb 06 '24 07:02 Jyy10

This is very important to us too. We too need to have access to the user agent.

Someone please respond and let us know when this issue will be resolved.

lifehetu avatar Feb 19 '24 18:02 lifehetu

@swaminator by any chance, do you have any news on this regard?

yannicklescure avatar Mar 01 '24 21:03 yannicklescure

I got the same issue, SSR on vercel is too slow, Amplify is better but got this problem, i don't know why a problem was affected to many developer that AWS does not resolve it My website can not check to display mobile menu: https://kapanda.com/

quannv avatar Apr 05 '24 04:04 quannv

CloudFront implemented a solution for this a couple of years ago to control origin request headers so CloudFront can forward on the user-agent header without it being part of the CloudFront cache key:

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/controlling-origin-requests.html

I don't understand why Amplify won't give us this option, or even just expose the CloudFront distribution that Amplify creates behind-the-scenes so we can edit the settings in CloudFront.

p00000001 avatar May 09 '24 17:05 p00000001

bump

fabio-carvalho88 avatar May 29 '24 09:05 fabio-carvalho88

CloudFront implemented a solution for this a couple of years ago to control origin request headers so CloudFront can forward on the user-agent header without it being part of the CloudFront cache key:

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/controlling-origin-requests.html

I don't understand why Amplify won't give us this option, or even just expose the CloudFront distribution that Amplify creates behind-the-scenes so we can edit the settings in CloudFront.

CloudFront implemented a solution for this a couple of years ago to control origin request headers so CloudFront can forward on the user-agent header without it being part of the CloudFront cache key:

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/controlling-origin-requests.html

I don't understand why Amplify won't give us this option, or even just expose the CloudFront distribution that Amplify creates behind-the-scenes so we can edit the settings in CloudFront.

can this be used as a workaround? it would imply extra costs, right?

fabio-carvalho88 avatar May 29 '24 09:05 fabio-carvalho88

@Jay2113 any plans on this please?

belyas avatar May 29 '24 10:05 belyas

bump

hunganhAtWhill avatar Jun 03 '24 00:06 hunganhAtWhill

bump!

StefanAleksik avatar Jun 05 '24 22:06 StefanAleksik

we have to set custom-user-agent for integrate with another solution any planon this?

bigtechsolution avatar Jun 07 '24 06:06 bigtechsolution

any update here ? we are unable to find user device user-agent on server side, it shows cloudfront

anujmedpay avatar Jun 07 '24 06:06 anujmedpay

CloudFront implemented a solution for this a couple of years ago to control origin request headers so CloudFront can forward on the user-agent header without it being part of the CloudFront cache key: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/controlling-origin-requests.html I don't understand why Amplify won't give us this option, or even just expose the CloudFront distribution that Amplify creates behind-the-scenes so we can edit the settings in CloudFront.

can this be used as a workaround? it would imply extra costs, right?

@fabio-carvalho88 I don't think it's something we can do without a technical change from AWS. My understanding is each AWS Amplify instance is packaged with a hidden instance of Cloudfront, and we do not have access to change any of its settings.

p00000001 avatar Jun 07 '24 07:06 p00000001

CloudFront implemented a solution for this a couple of years ago to control origin request headers so CloudFront can forward on the user-agent header without it being part of the CloudFront cache key: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/controlling-origin-requests.html I don't understand why Amplify won't give us this option, or even just expose the CloudFront distribution that Amplify creates behind-the-scenes so we can edit the settings in CloudFront.

can this be used as a workaround? it would imply extra costs, right?

@fabio-carvalho88 I don't think it's something we can do without a technical change from AWS. My understanding is each AWS Amplify instance is packaged with a hidden instance of Cloudfront, and we do not have access to change any of its settings.

yup, that's what I think as well... :/

fabio-carvalho88 avatar Jun 11 '24 14:06 fabio-carvalho88

in my case , i migrate from amplify to sstv2 because of this reason if you want to change user-agent then i recommed to use sstv2

hidon84 avatar Jun 12 '24 09:06 hidon84

@hidon84 whats sstv2 ?

anujmedpay avatar Jun 12 '24 10:06 anujmedpay

I'm having the same issue, I'm thinking of migrating to Google Cloud Run because of this. My app depends on the user agent to detect what link to serve to the user, what features are available and how to communicate to the device.

Also, this project has not been actively worked in months, I'm afraid it might be abandoned. Are there any other alternatives we can use with AWS or should I just move out?

nosmirck avatar Jun 18 '24 11:06 nosmirck

@hidon84 whats sstv2 ? this is https://sst.dev/

it use opennext , and work perfectly in my use case. if you want cloudfront mannually , then i recommed this project

hidon84 avatar Jun 18 '24 12:06 hidon84

bump

andrei1101011 avatar Jul 19 '24 11:07 andrei1101011

This feature has just been supported with our latest launch! Closing.

Check out the details here: https://aws.amazon.com/blogs/mobile/cdn-caching-improvements-for-better-app-performance-with-aws-amplify-hosting/

mauerbac avatar Aug 13 '24 18:08 mauerbac

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.

github-actions[bot] avatar Aug 13 '24 18:08 github-actions[bot]

This issue has been automatically locked.

github-actions[bot] avatar Aug 13 '24 19:08 github-actions[bot]