Socket.io - How to get client URL request on server side?

后端 未结 2 2047
隐瞒了意图╮
隐瞒了意图╮ 2021-02-10 00:50

In my app.js (server) I need to know from where (URL) the request came.

Currently, I\'m passing the URL as parameter from the client:

socket.emit(\'reque         


        
2条回答
  •  爱一瞬间的悲伤
    2021-02-10 01:25

    For the entire URL you could use socket.handshake.headers.referer

    io.on('connect', (socket) => {
         console.log(socket.handshake.headers.referer);
    });
    

提交回复
热议问题