Currently i'm using NodeJS & Express and obtaining the hostname from req.hostname
, e.g. example.com
However, when the client call the API (e.g. http://example.com/hello
), if the client change the host
value from the http header (e.g. change to bar.com
), the result obtain from req.hostname
(where the example.com
hosted) will return bar.com
instead of example.com
.
Anyone know how to get the real origin hostname from nodejs?
Edit: @Marc suggest to check against local env variable
However, the application is shared among multiple domains, it only helps when the application is using by 1 domain.