diff --git a/lib/fileServer.js b/lib/fileServer.js index 2a9946c..d7356eb 100644 --- a/lib/fileServer.js +++ b/lib/fileServer.js @@ -32,7 +32,6 @@ handleResponse = function (request, response) { // Handle only GET requests for /nowjs/* files. Pass all other requests through var i; if (request.method === 'GET') { - // Detect if request involves the now.js file if (request.url.split('?')[0] === '/nowjs/now.js') { serveFile(__dirname + nowClient, request, response, options); @@ -75,8 +74,7 @@ serveFile = function (filename, request, response, options) { // Determine hostname / port if not given in options var host = request.headers.host.split(':'); var hostServer = options['host'] || host[0]; - var hostPort = options['port'] || host[1] || '80'; - + var hostPort = options['port'] || host[1] || ((request.headers.referer.split(':')[0] === 'https') ? '443' : '80'); // Call generate client libs, which takes the desired host/port and executes callback with two parts of now.js as parameters generateClientLibs(hostServer, hostPort, function (nowText) {