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

前端 未结 2 675
醉话见心
醉话见心 2021-01-31 02:40

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条回答
  • 2021-01-31 03:03

    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"
    
    0 讨论(0)
  • 2021-01-31 03:12

    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

    0 讨论(0)
提交回复
热议问题