How do I get socket.io running for a subdirectory

前端 未结 4 1866
广开言路
广开言路 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:23

    In my case I am using nginx as a reverse proxy. I was getting 404 errors when polling. This was the solution for me.

    The url to the node server is https://example.com/subdir/

    In the app.js I instantiated the io server with

    var io = require('socket.io')(http, {path: '/subdir/socket.io'});
    

    In the html I used

    socket = io.connect('https://example.com/subdir/', {
        path: "/subdir"
    });
    

    Cheers,
    Luke.

提交回复
热议问题