diff --git a/templates/bin/node/http-server/http-server b/templates/bin/node/http-server/http-server index f6b2cab81..2c073630c 100755 --- a/templates/bin/node/http-server/http-server +++ b/templates/bin/node/http-server/http-server @@ -2,9 +2,11 @@ var colors = require('colors'), httpServer = require('./http-server.js'), - argv = require('optimist').argv, portfinder = require('portfinder'), - opener = require('opener'); + opener = require('opener'), + argv = require('optimist') + .boolean('cors') + .argv; if (argv.h || argv.help) { console.log([ @@ -19,8 +21,13 @@ if (argv.h || argv.help) { " -s --silent Suppress log messages from output", " --cors Enable CORS via the 'Access-Control-Allow-Origin' header", " -o Open browser window after staring the server", - " -c Set cache time (in seconds). e.g. -c10 for 10 seconds.", + " -c Cache time (max-age) in seconds [3600], e.g. -c10 for 10 seconds.", " To disable caching, use -c-1.", + "", + " -S --ssl Enable https.", + " -C --cert Path to ssl cert file (default: cert.pem).", + " -K --key Path to ssl key file (default: key.pem).", + "", " -h --help Print this list and exit." ].join('\n')); process.exit(); @@ -29,6 +36,7 @@ if (argv.h || argv.help) { var port = argv.p || parseInt(process.env.PORT, 10), host = argv.a || '0.0.0.0', log = (argv.s || argv.silent) ? (function () {}) : console.log, + ssl = !!argv.S || !!argv.ssl, requestLogger; if (!argv.s && !argv.silent) { @@ -58,19 +66,31 @@ function listen(port) { }; if (argv.cors) { - options.headers = { 'Access-Control-Allow-Origin': '*' }; + options.headers = { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept' + }; + } + + if (ssl) { + options.https = { + cert: argv.C || argv.cert || 'cert.pem', + key: argv.K || argv.key || 'key.pem' + }; } var server = httpServer.createServer(options); server.listen(port, host, function() { + var uri = [ssl ? 'https' : 'http', '://', host, ':', port].join(''); log('Starting up http-server, serving '.yellow + server.root.cyan - + ' on port: '.yellow - + port.toString().cyan); - log('Hit CTRL-C to stop the server'); + + ((ssl) ? ' through'.yellow + ' https'.cyan : '') + + ' on: '.yellow + + uri.cyan); + log('Hit CTRL-C to stop the server'); if (argv.o) { - opener('http://127.0.0.1:' + port.toString()); + opener(uri); } }); } @@ -83,4 +103,4 @@ if (process.platform !== 'win32') { log('http-server stopped.'.red); process.exit(); }); -} +} \ No newline at end of file diff --git a/templates/bin/node/http-server/package.json b/templates/bin/node/http-server/package.json index 8ad9ea3f9..61f42f4fd 100755 --- a/templates/bin/node/http-server/package.json +++ b/templates/bin/node/http-server/package.json @@ -1,6 +1,6 @@ { "name": "http-server", - "version": "0.6.1", + "version": "0.7.4", "author": "Nodejitsu ", "description": "a simple zero-configuration command-line http server", "main": "./lib/http-server", diff --git a/tools/helpers/HTML5Helper.hx b/tools/helpers/HTML5Helper.hx index 9e60442fc..68def0b11 100644 --- a/tools/helpers/HTML5Helper.hx +++ b/tools/helpers/HTML5Helper.hx @@ -124,14 +124,14 @@ class HTML5Helper { LogHelper.info ("", " - \x1b[1mStarting local web server:\x1b[0m http://localhost:" + port); - Thread.create (function () { + /*Thread.create (function () { Sys.sleep (0.5); ProcessHelper.openURL ("http://localhost:" + port); - }); + });*/ - var args = [ server, path, "-p", Std.string (port), "-c-1" ]; + var args = [ server, path, "-p", Std.string (port), "-c-1", "-o", "-a", "localhost", "--cors" ]; if (!LogHelper.verbose) {