peers / peerjs-server

Server for PeerJS
https://peerjs.com
MIT License
4.38k stars 1.09k forks source link

Peer server /id endpoint not working #169

Closed antonky closed 4 years ago

antonky commented 4 years ago

I set up the peer server and the id endpoint doesn't work as shown on the README The README states

Open http://127.0.0.1:9000/myapp/peerjs/id to see a new random id.

This actually 404s I looked at your code, and the route to get the random id is http://127.0.0.1:9000/myapp/peerjs/<literally anything you want>/id So between /peerjs/ and /id/ theres a param called :key which never gets used in your code, but it is required to get an id So how am I supposed to use this with the PeerJS library? Since it will make a request to 127.0.0.1:9000/myapp/peerjs/id

afrokick commented 4 years ago

@nakamin please provide your server side code

antonky commented 4 years ago

Sure, here's the code:

import * as http from "http";
import express from "express";
import { ExpressPeerServer } from "peer";

const app = express();
const server = http.createServer(app);

// peerjs
const peerServer = ExpressPeerServer(server, {
    proxied: true,
    path: "/"
});
app.use("/peerjs", peerServer);

const PORT = process.env.PORT || 5000;
server.listen(PORT);

My app is deployed on Heroku, peerjs endpoint works: https://synctune.herokuapp.com/peerjs The id endpoint does not https://synctune.herokuapp.com/peerjs/id

Adding the key in between makes it work: https://synctune.herokuapp.com/peerjs/hello/id

Also I'm having an issue with the peer server itself, when I try to connect I get this error: image

afrokick commented 4 years ago

https://github.com/peers/peerjs-server/blob/master/src/api/README.md

From README:

GET /:key/id - return a new user id. required :key from config.

afrokick commented 4 years ago

Which version of peer did you use? Try to use the latest 0.5.2

antonky commented 4 years ago

I just deployed the peer server separately, it works now 🤷‍♂️