Skip to content

TimDaub/ssl-serve

 
 

Repository files navigation

ssl-serve

Note by Tim Daubenschütz

During a re-write vercel removed the support for serve's --ssl flag. However, a user named jwarby pointed out that version 6 still included it and was working fine. I noticed that version 6 had vulnerabilities though, so I decided to fork v6 of vercel/serve to remove them.

I'm likely to maintain this package as I'm planning on using it in my projects.

Usage

npm install -g ssl-serve

Once that's done, you can run this command inside your project's directory:

serve [options] <path>

Serve Content Via HTTP and automatic SSL Cert generation

Just use the --ssl option. Make sure to accept the self-signed certificate in your browser too.

Options

Run this command to see a list of all available options:

serve help

Authentication

If you set the --auth flag, the package will look for a username and password in the SERVE_USER and SERVE_PASSWORD environment variables.

As an example, this is how such a command could look like:

SERVE_USER=leo SERVE_PASSWORD=1234 serve --auth

API

You can also use the package inside your application. Just load it:

const serve = require('serve')

And call it with flags (run this command for the full list):

const server = serve(__dirname, {
  port: 1337,
  ignore: ['node_modules']
})

Later in the code, you can stop the server using this method:

server.stop()

Contributing

I'm happy to merge contributor's PRs.

License

See License.

Authors

Leo Lamprecht (@notquiteleo) - Vercel Tim Daubenschuetz tim.daubenschuetz@gmail.com

About

Static file serving and directory listing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 72.3%
  • CSS 23.4%
  • Handlebars 4.3%