zumzum
zumzum

Reputation: 20248

Find host in node.js?

I am writing an app and in a function I'd like to know what is the current host. If I have the request object I've been able to do: req.headers.host that returns something like localhost:3000

I am trying to get the same thing, so find out the current host, when I'm in a module that has no request object. How can I know the host with no req object?

Upvotes: 0

Views: 341

Answers (1)

Ry-
Ry-

Reputation: 225273

You need to pass the request object somehow. There is no other way.

Upvotes: 3

Related Questions