get url after “#” in express.js middleware request

后端 未结 2 808
Happy的楠姐
Happy的楠姐 2020-12-04 01:18

I need to get url on server middleware (using express.js). I use req.url but when url starts from /#some/url req.url returns /...

2条回答
  •  再見小時候
    2020-12-04 02:04

    Use the built-in url module which is available in Node.js to parse the URL and create a urlObject. This will have a hash fragment property containing the hash fragment you want.

    const url = require('url')
    const urlObj = url.parse(req.url)
    console.log(urlObj.hash) // #some/url
    

提交回复
热议问题