Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACCEPT header stripped off by Amplify before forwarding request to target server #2316

Closed
4 tasks done
ssontakke opened this issue Oct 12, 2021 · 10 comments
Closed
4 tasks done
Labels
archived This issue has been locked. feature-request New feature or request

Comments

@ssontakke
Copy link

ssontakke commented Oct 12, 2021

Before opening, please confirm:

App Id

arn:aws:amplify:us-west-2:840725391265:apps/d2i6qlt8w44ey

Region

us-west-2

Amplify Console feature

Not applicable

Describe the bug

Context
We have a web application which has a functionality to download pdf, csv, xls, etc. Frontend hosted on Amplify and is a SPA. Frontend requests are routed to different external endpoints through Amplify Redirection/Rewrite Rules.

Here is what is happening:
Browser sends requests to Amplify hosted site - domain.com/some-unique-path to download a PDF. Request headers has ACCEPT = application/pdf.

Amplify has a redirection rule -

{
 "source": "/some-unique-path/<*>",
 "target": "https://subdomain.domain.com/<*>",
 "status": "200",
 "condition": null
}

On target server subdomain.domain.com, we are not receiving the ACCEPT header. We also noticed that CONTENT_TYPE, HTTP_ACCEPT headers are also empty on the target server.

Expected behavior

Amplify redirection shouldn't modify any headers. On the target server, we should get ACCEPT headers as it was passed by browser.

Reproduction steps

  1. Create a 200 redirection rule in Amplify like this:
{
 "source": "/some-unique-path/<*>",
 "target": "https://subdomain.domain.com/<*>",
 "status": "200",
 "condition": null
}
  1. Do a curl call to Amplify hosted site and set ACCEPT = 'application/pdf'
  2. Observe the headers received on target server. You will see ACCEPT header is stripped off.

Build Settings

No response

Additional information

No response

@github-actions
Copy link

Hi 👋, thanks for opening! While we look into this...

If this issue is related to custom domains, be sure to check the custom domains troubleshooting guide to see if that helps. Also, there is a more general troubleshooting FAQ that may be helpful for other questions.

Lastly, please make sure you've specified the App ID and Region in the issue!

@ghost ghost added question Further information is requested redirects labels Oct 13, 2021
@victorccccc
Copy link
Contributor

victorccccc commented Oct 13, 2021

Hi, unfortunately, we don't support forwarding these headers to your target server (reverse proxy) from Amplify managed distribution. According to https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html#request-custom-headers-behavior, Cloudfront removes some request headers while processing the request.

So, I'll mark this as a feature request. Thanks.

@victorccccc victorccccc added feature-request New feature or request and removed question Further information is requested redirects labels Oct 13, 2021
@Rafcin
Copy link

Rafcin commented Oct 14, 2021

#8446 Somewhat related to this, when deploying a Next app, hosting won't allow me to use the cloudfront geolocation headers. Setting them manually in cloudfront won't work and they end up being overwritten by each build. I think Amplify should add a configuration option for cloudfront to allow us to use the service to the fullest potential. I have an app that relies on a users location, for me it would be cheaper to use the cloudfront headers rather than have to set up my own geoip service and resolve a location based on the uses IP. It would hurt my wallet less as well.

@fnavarrodev
Copy link

What's the status of this request?

@jmcpeak
Copy link

jmcpeak commented Sep 28, 2023

I need the referrer header in my next 13 app - how can I get it?

@yahya-evoly
Copy link

I need the referrer header in my next 13 app - how can I get it?

I reached out to AWS technical support regarding this issue recently. Unfortunately, they confirmed there's no direct solution at the moment. If anyone has discovered a workaround, I'd be keen to hear about it!

@jmcpeak
Copy link

jmcpeak commented Sep 28, 2023

Thanks for the response @yahya-evoly.

The AWS link @victorccccc gave for headers that are passed was very helpful.

@calavera
Copy link
Contributor

This feature has just been supported with our latest launch! I'm closing this issue as it's been resolved.

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

Copy link

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.

Copy link

This issue has been automatically locked.

@github-actions github-actions bot added the archived This issue has been locked. label Aug 13, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants