简体   繁体   中英

Get domain name with NodeJS

I'd like to get the domaine name using NodeJS.

My code: request.headers.host

It returns 127.0.0.1:3007 instead of http://domainname.fr ...

Edit #1:

{"host":"127.0.0.1:3007","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8","upgrade-insecure-requests":"1","user-agent":"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36","referer":"http://domainname.fr/option/seo/edit","accept-encoding":"gzip, deflate, sdch","accept-language":"en-US,en;q=0.8,ca;q=0.6,de;q=0.4,es;q=0.2,fil;q=0.2,fr;q=0.2,it;q=0.2,pt;q=0.2","cookie":"wp-settings-1=libraryContent%3Dbrowse%26post_dfw%3Doff%26hidetb%3D1%26editor%3Dtinymce; wp-settings-time-1=1453197454; _ga=GA1.2.1880128487.1451319866; connect.sid=s%3A6rtTBduaUul9Q0o_p7vxF6TzmMcfQs19.kaBdkoGAeQtQuxHsfwDsEscbOYFsZpnTIlluk2u0X0Q","x-forwarded-for":"86.207.238.8","x-forwarded-host":"domainname.fr","x-forwarded-server":"domainname.fr","connection":"Keep-Alive"}

Under the req.headers you can check for "origin" or "referer". Also, if you search for the initiator, you can find it under "from".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM