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

Forward the Host header to the origin #82

Open
DmitriyKabanov opened this issue Apr 10, 2023 · 6 comments
Open

Forward the Host header to the origin #82

DmitriyKabanov opened this issue Apr 10, 2023 · 6 comments
Labels
enhancement New feature or request internal Changes only affect the internal API

Comments

@DmitriyKabanov
Copy link

On the application layer we need to access the Host header in the request object, however it's not equal to any of alternative domain names.

As of now, header behaviour is hardcoded as CacheHeaderBehavior.allowList('accept', 'accept-language', 'content-language', 'content-type', 'user-agent', 'authorization').

Adding host to this list breaks the API Gateway with 403 error, unless API Gateway is configured with custom domain names.

@sladg
Copy link
Owner

sladg commented Apr 11, 2023

Yeah, ApiGw expects Host to be Cloudfront. We would need to do mapping of original Host to something like X-Host. I would need to take a look what is recommended way of doing this in AWS.

@sladg sladg added enhancement New feature or request internal Changes only affect the internal API labels Apr 12, 2023
@DmitriyKabanov
Copy link
Author

Any ETA on this?

@sladg
Copy link
Owner

sladg commented Apr 25, 2023

@DmitriyKabanov I did a research and to support this properly, we would need to create Edge Lambda that would handle renaming headers and forwarding them.
It's quite unfortunate as I'm very much trying to stay away from Edge lambda due to limitations and deployment speed. I'm experimenting with keeping Edge lambdas same after first deploy.

No ETA yet, definitely bigger task than expected.

Any chance you could provide me with your usecase? Aka. what are you using Host for? Maybe I can suggest workaround in the meantime.

@DmitriyKabanov
Copy link
Author

The use case is to build a redirectUrl to get back to the service.

@sladg
Copy link
Owner

sladg commented Apr 29, 2023

That sounds like something that can be done by many different ways.
For example:

  • if you are using API call, send hostname from client in request,
  • if you are doing this in SSR, use relative route or pass environment variable to lambda (such as APP_URL=https://my.app.com
  • if doing this on client, access it from window

@DmitriyKabanov
Copy link
Author

For sure, it could be done by many different ways.
I'm not opposed to put a temporary workaround (as we already did).
I'm curious when this enchantment would be addressed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request internal Changes only affect the internal API
Projects
None yet
Development

No branches or pull requests

2 participants