expressjs: get requested url

后端 未结 4 1903
情深已故
情深已故 2021-02-19 07:02

I want to get the url the client has requested out of the request.

Currently I use:

var requestedUrl = req.protocol + \'://\' + req.host + \':3000\' + re         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-19 07:23

    I'm afraid that pretty much all you can do. Unless you using https you can assume the protocol as http. As Raoul said you are not able to get anything after # server-side, that's for the browser

       var requestedUrl =  'http://' + req.headers.host + ':3000'  + req.url
    

提交回复
热议问题