How do I get the domain originating the request in express.js?

前端 未结 4 835
栀梦
栀梦 2020-12-01 00:25

I\'m using express.js and i need to know the domain which is originating the call. This is the simple code

app.get(
    \'/verify_license_key.json\',
    fun         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 01:06

    Recently faced a problem with fetching 'Origin' request header, then I found this question. But pretty confused with the results, req.get('host') is deprecated, that's why giving Undefined. Use,

        req.header('Origin');
        req.header('Host');
        // this method can be used to access other request headers like, 'Referer', 'User-Agent' etc.
    

提交回复
热议问题