Coder Social home page Coder Social logo

Cross-origin issue about peerjs-server HOT 34 CLOSED

peers avatar peers commented on April 28, 2024
Cross-origin issue

from peerjs-server.

Comments (34)

zovt avatar zovt commented on April 28, 2024

I have the same issue. Any new info?

from peerjs-server.

michelle avatar michelle commented on April 28, 2024

Ah, sorry for the delay in answering--that's really strange. Is this Firefox only?

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

Seems so, everything worked fine in Chrome.

EDIT: I should add that I'm using node.js to set up the peerjs server using a self-signed certificate for testing purposes. I'm also using nginx to serve up the static content, but have a proxy set up for anything dynamic to pass it to nodejs. I can post my nginx.conf and both the client and server code I am using if it helps

from peerjs-server.

michelle avatar michelle commented on April 28, 2024

Yeah, the server code would be helpful. Do you find that this still happens without nginx (just using something simple to serve statics?) Are you trying with the chat demo?

from peerjs-server.

michelle avatar michelle commented on April 28, 2024

I've just pushed a hack that will fix CORS issues with restify. The real fix will come when we switch back to express (I really hope to find some time to do that this weekend, so in the meantime I will leave this issue open).

At the time we built the server, we chose to use restify over express because it was leaner. However, express is now much better than it was before, and has a much support than restify does, so it makes sense to switch back.

This same bug also exists on the cloud server right now, and I'll also fix that as soon as we switch over to express.

from peerjs-server.

michelle avatar michelle commented on April 28, 2024

(Let me know if the latest patch, 0.2.7 doesn't fix this issue for you!)

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

Still no dice. Would you like me to post the server and client code?

from peerjs-server.

michelle avatar michelle commented on April 28, 2024

Hum, that's strange. Yeah that'd be helpful. What'd also help is a dump of
the request you're sending (from the network panel equivalent in FF, I
guess!)

Michelle

On Fri, Aug 29, 2014 at 10:46 AM, Ragesalmon [email protected]
wrote:

Still no dice. Would you like me to post the server and client code?


Reply to this email directly or view it on GitHub
#49 (comment).

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

Sure thing. Here's the error I'm getting in firefox

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://localhost:9000/peer/peerjs/lF1J56BNg762Uu5y/1d6aecjftkt/id?i=0. This can be fixed by moving the resource to the same domain or enabling CORS.

Server Code:

var ps = new PeerServer({
    path: '/peer/',
    port: 9000,
    ssl: {
    key: fs.readFileSync('../ssl/server.key'),
    certificate: fs.readFileSync('../ssl/server.crt')
    }
});

Client code:

peer = new Peer(id, {host: 'localhost', port: 9000, path: "/peer/"});

Would you like me to post my nginx config as well?

from peerjs-server.

michelle avatar michelle commented on April 28, 2024

Nah, that's fine. I think what'd be most helpful is the request dump--what
headers is the request sending, what's the actual method it's failing on,
etc.

Michelle

On Fri, Aug 29, 2014 at 10:57 AM, Ragesalmon [email protected]
wrote:

Sure thing. Here's the error I'm getting in firefox

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://localhost:9000/peer/peerjs/lF1J56BNg762Uu5y/1d6aecjftkt/id?i=0. This can be fixed by moving the resource to the same domain or enabling CORS.

Server Code:

var ps = new PeerServer({
path: '/peer/',
port: 9000,
ssl: {
key: fs.readFileSync('../ssl/server.key'),
certificate: fs.readFileSync('../ssl/server.crt')
}
});

Client code:

peer = new Peer(id, {host: 'localhost', port: 9000, path: "/peer/"});

Would you like me to post my nginx config as well?


Reply to this email directly or view it on GitHub
#49 (comment).

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

https://i.imgur.com/dAW2tDS.png

There are two requests at the bottom of the log, and neither of them have any response data. I could get the dump from chrome as well, which works.

from peerjs-server.

michelle avatar michelle commented on April 28, 2024

Hm! But they no longer 405 as before?

Michelle

On Fri, Aug 29, 2014 at 11:18 AM, Ragesalmon [email protected]
wrote:

https://i.imgur.com/dAW2tDS.png

There are two requests at the bottom of the log, and neither of them have
any response data. I could get the dump from chrome as well, which works.


Reply to this email directly or view it on GitHub
#49 (comment).

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

Seems so. The only thing showing up now is the CORS issue in console

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

Just a question, have you been able to reproduce the bug on your end? If it helps, I'm using the latest firefox nightly

from peerjs-server.

michelle avatar michelle commented on April 28, 2024

I haven't been able to reproduce, but I am on Firefox stable. I'll try
nightly :).

Michelle

On Fri, Aug 29, 2014 at 1:42 PM, Ragesalmon [email protected]
wrote:

Just a question, have you been able to reproduce the bug on your end? If
it helps, I'm using the latest firefox nightly


Reply to this email directly or view it on GitHub
#49 (comment).

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

Alright. I can boot up firefox stable and give it a shot.

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

Just tried it on stable, still the same error

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

I should also note that I am using socket.io with no problem, if that changes anything

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

I'm going to try using something simpler than nginx to serve the pages. Does this project work better with express or restify?

from peerjs-server.

michelle avatar michelle commented on April 28, 2024

Did you confirm it's an nginx issue?

On Friday, August 29, 2014, Ragesalmon [email protected] wrote:

I'm going to try using something simpler than nginx to serve the pages.
Does this project work better with express or restify?


Reply to this email directly or view it on GitHub
#49 (comment).

Sent from Gmail Mobile

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

Not yet. I've been working all day, so I'm taking a bit of a break. I'll update as soon as I test it.

from peerjs-server.

michelle avatar michelle commented on April 28, 2024

Thanks, that'd be amazing :). I'm just getting around to trying more things
now, too.

Michelle

On Fri, Aug 29, 2014 at 9:28 PM, Ragesalmon [email protected]
wrote:

Not yet. I've been working all day, so I'm taking a bit of a break. I'll
update as soon as I test it.


Reply to this email directly or view it on GitHub
#49 (comment).

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

Thanks for all your help! i really appreciate it

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

Hi! Sorry for the delay. Unfortunately, no matter what webserver we tested, we still had the issue with the CORS request.

from peerjs-server.

michelle avatar michelle commented on April 28, 2024

We've just switched over to using Express. Hopefully this helps!

from peerjs-server.

michelle avatar michelle commented on April 28, 2024

Also just upgraded the CORS middleware we're using.

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

Thanks! I'll check sometime this week

from peerjs-server.

peveuve avatar peveuve commented on April 28, 2024

In case you still wonder what happened, the problem is very likely that the certificate used is self-signed. In the context of a secured web page, browsers block such unsecured requests, so adding CORS response headers is useless.
Either use a real certificate, or load the called URL once in your browser so you can add a security exception and load the certificate.
I had the same issue today when switching the HTTPS in Dev, quite annoying but nothing to do with PeerJS.

from peerjs-server.

zovt avatar zovt commented on April 28, 2024

@peveuve thanks man, seems that this was the issue <3 and thanks @michelle for working to fix it.

from peerjs-server.

fyyyyy avatar fyyyyy commented on April 28, 2024

Having this issue with build:0.3.13 and Firefox 35.0.1
I did not see this issue before upgrading from 0.3.9 to 0.3.13 yesterday. Happens on localhost with express server. I will look into certificates.

from peerjs-server.

bitnom avatar bitnom commented on April 28, 2024

Same issue on both Chrome and Firefox CORS header ‘Access-Control-Allow-Origin’ missing

I'm running: bin/peerjs --port 8880 --key myKey123 --path /broker

from peerjs-server.

merksam avatar merksam commented on April 28, 2024

Guys, if I'm not mistaken you can run express version of peerjs-server and add cors package to allow cross-origin requests.

from peerjs-server.

nboulikas avatar nboulikas commented on April 28, 2024

Guys, if I'm not mistaken you can run express version of peerjs-server and add cors package to allow cross-origin requests.

How?

from peerjs-server.

peerjs-bot avatar peerjs-bot commented on April 28, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from peerjs-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.