How do I find the a referring sites URL in node?

2020-05-18 04:38发布

How do I find the a referring sites URL in node?

I'm using express, would I find this in the headers on connect or something?

Thanks!

2条回答
太酷不给撩
2楼-- · 2020-05-18 05:26

If you mean how do you get it when running an express server, then it's done using the header method on your request:

req.header('Referer');
// => "http://google.com"
查看更多
仙女界的扛把子
3楼-- · 2020-05-18 05:36

In express 4.x:

req.get('Referrer')

This will also check both spellings of referrer so you do not have to do:

 req.headers.referrer || req.headers.referer

Here is the documentation

查看更多
登录 后发表回答