My html code
var url='ws://localhost:8000/abc';
socket=new WebSocket(url);
socket.onopen=function(){
log('Success');
}
in php or node.js how to get url path abc?
If you're using the ws library for node you can get the URL from the second argument to ws.connection
which is the request object:
const server = new http.createServer()
const wss = new WebSocket.Server({ server })
wss.on('connection', (ws, req) => {
console.log(req.url)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With