JSPM

  • Created
  • Published
  • Downloads 85959
  • Score
    100M100P100Q154730F
  • License AGPL-3.0

HTTPS server running on localhost

Package Exports

  • https-localhost

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (https-localhost) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

HTTPS server running on localhost

Run an express server on localhost with HTTP2 and SSL for free.

Serve static files or import as module in your project.

NPM

Build status Coverage Status Dependency Status Known Vulnerabilities GitHub issues npm version

Install and trust the certificate

Add the root certificate we just generated to your list of trusted certificates. This step depends on the operating system you're running:

  • Mac OS: open Keychain Access, choose System from the left navigation bar, choose "Import items..." from the File app menu and select the file. Then double-click on the certificate and select always-trust in the Trust panel.

  • Linux: Depending on your Linux distribution, you can use trust, update-ca-certificates or another command to mark the generated root certificate as trusted.

Run

Use standalone

From terminal navigate into the folder and run sudo npm install -g to install this tool globally.

Then serve static file with sudo serve <static-path>.

Use as module

Install the dependency with npm install -s https-localhost.
Then just require this module, it will start the server automatically.

For example, put in your index.js file:

const app = require("https-localhost")
app.get("/", (req, res) => res.send("Hello World!"))

Specify the port

You can specify the port number of the SSL port with sudo PORT=<port-number> serve <static-path> or from another module with process.env.PORT = <port-number>.

If you specify a port number the http redirect to https will be disabled. You can activate the http redirect again specifying not only the PORT environment variable but also the HTTP_PORT one.


License

AGPL-3.0