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

Host header in my SSR pages or APIs #156

Closed
Blue-Lamp opened this issue Jul 6, 2021 · 2 comments · Fixed by #161
Closed

Host header in my SSR pages or APIs #156

Blue-Lamp opened this issue Jul 6, 2021 · 2 comments · Fixed by #161
Labels
bug Something isn't working component/proxy
Milestone

Comments

@Blue-Lamp
Copy link

When accessing the Host header in my SSR pages or APIs, I get an API Gateway domain instead of the CloudFront distribution or my domain name.

https://github.com/serverless-nextjs/serverless-next.js#when-accessing-the-host-header-in-my-ssr-pages-or-apis-i-get-an-s3-domain-instead-of-the-cloudfront-distribution-or-my-domain-name

@ofhouse
Copy link
Member

ofhouse commented Jul 6, 2021

Hi, thanks for the report.

Yes, we change the host header in the proxy component to match the host of the API Gateway.
This happens because we don't add custom domains to the API Gateway distribution and therefore the gateway would reject requests from foreign hosts.

Unfortunately we don't change the header back to the original host from the viewer before calling the Lambda which causes that the API or SSR pages see the internal API Gateway endpoint as host.

Proposed solution:

  1. We add a new header x-forwarded-host in the proxy component that contains the original host header from the viewer when we change the host header to API Gateway endpoint.
  2. Before calling the Lambda (in node-bridge) we then replace the host header with the value from x-forwarded-host.

Will take a look soon 👍

@ofhouse ofhouse added bug Something isn't working component/proxy labels Jul 6, 2021
@ofhouse ofhouse added this to the v0.9.2 milestone Jul 13, 2021
@ofhouse ofhouse modified the milestones: v0.9.2, v0.9.3 Sep 18, 2021
@ofhouse ofhouse closed this as completed Oct 3, 2021
@ofhouse
Copy link
Member

ofhouse commented Oct 16, 2021

This has now been fixed in v0.10.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component/proxy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants