Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

req.headers['x-forwarded-host'] is undefined on netlify deployment #46

Closed
abdelhamid-attaby opened this issue Oct 2, 2020 · 11 comments · Fixed by #54
Closed

req.headers['x-forwarded-host'] is undefined on netlify deployment #46

abdelhamid-attaby opened this issue Oct 2, 2020 · 11 comments · Fixed by #54

Comments

@abdelhamid-attaby
Copy link

This issue is exactly the same issue statued here #40 but with x-forwarded-host header.

@lindsaylevine
Copy link
Contributor

thanks for pointing this out! there's an internal netlify PR open as of 7 hours ago to address the original issues you referenced (regarding req.headers.host) and my hope is the internal PR can cover x-forwarded-host as well. will keep you updated!

@lindsaylevine
Copy link
Contributor

update: it seems like x-forwarded-host is the same as host so i'm not sure this needs to be added

https://vercel.com/docs/edge-network/headers#x-forwarded-host

@abdelhamid-attaby
Copy link
Author

@lindsaylevine the documentation you posted is about Vercel. x-forwarded-host is used mainly in proxies which is the case I am in now.

@lindsaylevine
Copy link
Contributor

@abdelhamid-attaby gotcha, i hear you! i linked the vercel docs primarily as an example. it's the same on netlify. for good measure i synced back with the team and internally we don't want to make the x-forwarded-host change because you should be able to use host. if you can demonstrate a specific need for x-forwarded-host that host does not resolve, i'd be happy to explore further for you! :)

@abdelhamid-attaby
Copy link
Author

@lindsaylevine thanks for taking this seriously. Mainly our setup now as following: caddyserver (as a proxy and ssl certificates manager) -> Netlify . So, in order for Netlify to understand the website, caddy should put the host header to be the upstream address (which is the Netlify address in this case). However, in the application itself, we need to know the original host the user asked for (which should be in x-forwarded-host).

@lindsaylevine
Copy link
Contributor

@abdelhamid-attaby of course! and i hear you. are you comfortable opening a PR? swamped with other priorities at the moment, but if this is a blocker/priority for you, that's probably the best way to get it addressed asap :)

@brenelz
Copy link

brenelz commented Oct 14, 2020

Might be able to just fix it doing something like the following. It seems like you removed the code from issue #40 tho

  if(!event.multiValueHeaders.hasOwnProperty('x-forwarded-host')) {
    event.multiValueHeaders['x-forwarded-host'] = [event.headers['host']]
  }

@lindsaylevine
Copy link
Contributor

@brenelz yeah we took it out because it was only in next-on-netlify as a temporary patch. host is now provided on multiValueHeaders by netlify internally. however, whenever i've synced with the internal team who made that change, they insist host should suffice for x-forwarded-host and don't want to make that specific change internally.

are you experiencing this issue too @brenelz?

@brenelz
Copy link

brenelz commented Oct 14, 2020

no not experiencing the issue... was just trying to help out. Happend to just try out the next-on-netlify package though and its pretty slick. Keep up the good work!

@lindsaylevine
Copy link
Contributor

yk what there's really no harm in adding it. will open a PR now since i have a minute! cc @abdelhamid-attaby

thanks for the kind words @brenelz <3 it's all @FinnWoelm

@abdelhamid-attaby
Copy link
Author

abdelhamid-attaby commented Oct 24, 2020

Thanks, @lindsaylevine, really appreciated your help. I am sorry I was so busy beyond opening this PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants