Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 1
    try: req.host or req.get('host') expresses docs Commented Aug 28, 2013 at 21:45
  • 3
    node.js: req.headers["x-forwarded-for"] || req.connection.remoteAddress x-forwarded-for would cover your bases behind a proxy, load balancer... Commented May 16, 2014 at 19:13
  • I get this warning: express deprecated req.host: Use req.hostname instead index.js:20:8 Commented Mar 8, 2015 at 3:15
  • "I need to know if the API was called by somesite.example". Note that the domain example.com is reserved specifically for use in examples: iana.org/domains/reserved Commented Jul 1, 2022 at 7:45