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

前端 未结 4 849
栀梦
栀梦 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:13

    Instead of:

    var host = req.get('host');
    var origin = req.get('origin');
    

    you can also use:

    var host = req.headers.host;
    var origin = req.headers.origin;
    

提交回复
热议问题