grunt-http-server@1.10.0 release supports SSL/HTTPS

Oscar Brito

grunt-http-server is a very useful grunt task that you can use while developing your web based projects. You can quickly add this task and start serving static content from your local machine.

Bonus tip: If you use Jasmine to write your tests you can serve the generated html with grunt-http-server and use the Browser developer tools to help you debug, profile, etc... your code.

HTTPS support

The new version of grunt-http-server was today released thanks to maxfriedmann pull request.

npm i grunt-http-server@1.10.0  

With this new version you can configure the grunt http-server task to serve https content.

There's no need to create self-signed certificates, you just need to do the following on your gruntfile.js.

module.exports = function(grunt) {

  grunt.initConfig({

    'http-server': {

        'example': {
            root   : "",
            host   : "127.0.0.1",
            port   : function(){ return 8585; },
            https  : true
        }
    }

  });

  // auto load tasks
  require('load-grunt-tasks')(grunt);

  grunt.registerTask(
    'default',
    [
        'http-server'
    ]);

};

Don't forget that because the certificate was not signed by a valid certificate authority you'll get a warning page on your browser that you need to ignore.

If you have the certificate and it's key you can also configure the task to use it. Please check the github page for all the options.

Oscar out.