Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path configuration is confusing and inconsistent with frontend PeerJS client config #234

Open
intellix opened this issue Jan 19, 2021 · 1 comment
Labels

Comments

@intellix
Copy link

intellix commented Jan 19, 2021

I have a suggestion:

Currently the suggestion is to do something like the following:

const peerServer = ExpressPeerServer(server);
app.use('/peerjs', peerServer);

This actually creates a binding on /peerjs/peerjs because inside the ExpressPeerServer middleware it's adding an app.use(options.path, xyz).

Alongside that, on the client there isn't double paths without being explicit:

const peer = new Peer('123', {
  host: 'localhost',
  port: 9001,
  path: '/peerjs/peerjs',
  secure: false,
  debug: 2,
  config: {
    iceServers,
  },
});

I think it would just be easier to understand if this:

const peerServer = ExpressPeerServer(server);
app.use('/peerjs', peerServer);

Created a binding on just /peerjs. I don't really understand why there's the ability to define an extra path on top.

There shouldn't be any automatic adding of paths anywhere. So you know exactly what you're writing is going to be the endpoint

@spine001
Copy link

You are correct, this is a big source of confusion, but changing the code simply to correct that would affect all the working code out there. I have found that most of the tutorials, if not all don't actually work. Often due to changes in the code. My suggestion is to improve the manual! I didn't know of this double app.use(....) that you mentioned here, and thanks to you now I do. I solved this by explicitly doing:

const peerServer = ExpressPeerServer(mainServer, {
        debug: true,
        path: '',
        ssl: {},
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants