Flotype / now

NowJS makes it easy to build real-time web apps using JavaScript
http://www.nowjs.com
MIT License
1.91k stars 175 forks source link

server.js serves now.js client with incorrect port for socket.io #167

Closed matthiasak closed 12 years ago

matthiasak commented 12 years ago

I have a server setup, which initializes on port 443.

With port 443, the now.js is served to the browser just fine. The issue is when the browser tries to pull in socket.io as well.

The socket.io file pointed to by now.js client file is at https://mysite:80 instead of :443. This is causing issues with now, obviously, and I wanted to serve from 443 since a lot of my client's firewalls block other ports.

Here's the final catch: The browser sees that I am pulling an https link and simply removes the :443 from the URL to grab socket io,

thus my script which should grab https://mysite:443/nowjs/now.js just grabs https://mysite/nowjs/now.js

this is the root cause of the issue, as if the browser were to call for the first link instead of the second, then socket.io would also be called over :443, but since it isnt the code in the fileServer.js simply serves the file over :80.

Is there any way around this?

steveWang commented 12 years ago

You could always disable autohosting and call nowInitialize yourself.

matthiasak commented 12 years ago

Not done that before. I've been looking for documentation on this but it seems the NowJS docs are lacking what it does. Could you toss me a few pointers?

steveWang commented 12 years ago

Set autoHost to false in the server-side configuration, and on the client side, add something like var now = nowInitialize("https://mysite:443");

I think this should work, but it's been a while since I've played around with NowJS extensively.

matthiasak commented 12 years ago

That does help! Thanks steve!

matthiasak commented 12 years ago
jechols commented 12 years ago

Should this be closed? It seems like a legitimate bug that should be addressed in nowjs, not worked around by everybody using it in a secure environment.