request headers host unexpectedly changed
Our app broke just now (today). We're a platform that allows users to set up subdomains, and we handle loading by checking the request host header, for the subdomain (or custom domain).
However, this is what we're getting for the request host header now, to our nextjs app:
Previously we got something like "subdomain.example.com", and now it's just a port it looks like.
Will the host header just be unuseable from now on, or will it be fixed? Thanks! π
19 Replies
Project ID:
63b7280d-bfb7-499f-89d2-73fd8e2a081b
63b7280d-bfb7-499f-89d2-73fd8e2a081b
^ screenshot is with
req.headers.host
(req: NextApiRequest)
also tried req.headers["x-forwarded-host"]
, but just got undefined
unfortunatelylooks like youre printing the local host, the external host is still passed by railway https://utilities.up.railway.app/raw
hm im not sure why - i also just noticed this issue after deploying our app (cause we also do sanity testing after deploys)
is https://utilities.up.railway.app/raw a test app? like does it get frequently deployed i wonder - just throwing out questions, since we didn't change any part of our code here at all with header host checking, and suddenly it breaks today
of course i have covered my bases, redeployed 5 minutes ago
and if youre thinking this is an issue with custom domains, theres this too https://subdomain.overr.net/raw
gotcha.. yea im not sure, why this is suddenly happening, this is what im running:
very tame, and this is what im getting back now,
idk why it's using the local's host, but just gonna strip referer for now, and hopefully someone else has the same issue as me..
X-Forwarded-Host
doesnt exist btw
maybe you want .hostname
?
or req.headers.get("Host")
dont know, i haven't done anything with next, i do know that this isnt an issue with railway, since as you can see from my utilities app the host header is indeed theregotcha, yea i think i'll just print out the entire headers, and try "Host"
or maybe
req.host
/ req.hostname
just try stuff lolnextjs is typed pretty well, so there's like not infinite options, but hopefully smth worksπ€
haha forgot about the types
types are great π i remember when i was just writing plain javascript a few years ago, can't imagine going back to that now, stuff would break all the time lol
i still only write js lol
My headers unfortunately, really don't know why host is not passing π€·ββοΈ
perhaps related to nextjs server? hopefully someone else runs into the issue too i guess π€
something to do with next for sure
nextUrl
?just did a bit more testing but not sure, nextjs's "raw headers" look similar (host is local), and nextjs middleware is also giving me the wrong host too (local). referer is perfectly fine though, dunno why.
luckily referer contains all the information i need anyways, so it's good enough for an app hotfix, hopefully on a different nextjs version, things do work, trying tmrw π€
looking forward to an update!
hi. i have the same problem. should i use referer or a solution has been found?
as I've mentioned previously, and demonstrated, there's nothing wrong with the host header