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

nowjs on secure (https) server problem #118

Closed czajah closed 13 years ago

czajah commented 13 years ago

I'm including now.js this way:

<script type="text/javascript" src="HTTPS://localhost:3000/nowjs/now.js">&lt;/script>

and it is ok but a problem is with automagic including socket.io.js because it is accessed via HTTP:

(The page at HTTPS://localhost:3000/szop ran insecure content from HTTP://localhost:3000/socket.io/socket.io.js.)

so GET http://localhost:3000/socket.io/socket.io.js fails.

steveWang commented 13 years ago

Couple of things that you'll need to change manually for this to work:

Line 434:

socket = new io.Socket('**SERVER**', {port: **PORT**, secure: true});

Line 453:

fileref.setAttribute("src", "//**SERVER**:**PORT**"+dependencies[i]['path']);
czajah commented 13 years ago

which file?

steveWang commented 13 years ago

now.js

czajah commented 13 years ago

ok, its something like this:

socket = new io.Socket('**SERVER**', {port: **PORT**,secure:"https"==scheme});

and

fileref.setAttribute("src", scheme+"://**SERVER**:**PORT**"+dependencies[i]['path']);

is there better way to obtain scheme/protocol name than

var scheme = function()
{
  var scripts = document.getElementsByTagName( 'script' );
  var srcUrlString = scripts[ scripts.length -1 ].src;

  // http://labs.apache.org/webarch/uri/rfc/rfc3986.html#regexp
  var urlParser = /^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/; 
  var splitResult = srcUrlString.split(urlParser);

  return splitResult[2];
}();

?

steveWang commented 13 years ago

The first part is good. The second part should just be what I said before. Don't bother trying to make some complicated regex that handles everything for you.

czajah commented 13 years ago

wow, i see :) lol

czajah commented 13 years ago

thank you