How do I get socket.io running for a subdirectory

前端 未结 4 1867
广开言路
广开言路 2021-02-02 10:46

I\'ve got a proxy running that only hits my node.js server for paths that being with /mysubdir How do I get socket.io configured for this situation?

In my c

4条回答
  •  说谎
    说谎 (楼主)
    2021-02-02 11:27

    The answer by @Drew-LeSueur is correct for socket.io >= 1.0.

    As I was using socket.io 0.9, I found the old way of doing it in the doc.

    // in 0.9
    var socket = io.connect('localhost:3000', {
      'resource': 'path/to/socket.io';
    });
    
    // in 1.0
    var socket = io.connect('localhost:3000', {
      'path': '/path/to/socket.io';
    });
    

    Notice that a / appears as first character in the new path option.

提交回复
热议问题