Skip to content

Instantly share code, notes, and snippets.

@syuji-higa
Created August 21, 2020 09:20
Show Gist options
  • Save syuji-higa/5b44fa5985af2bd91c6466f4c976dbfb to your computer and use it in GitHub Desktop.
Save syuji-higa/5b44fa5985af2bd91c6466f4c976dbfb to your computer and use it in GitHub Desktop.
Node.js - https local server
const { join } = require('path')
const { readFileSync } = require('fs')
const express = require('express')
const app = express()
const https = require('https')
app.use(express.static(join(__dirname, 'docs')))
const server = https.createServer({
key: readFileSync('localhost-key.pem'),
cert: readFileSync('localhost.pem')
}, app)
const host = 'localhost'
const port = 3000
server.listen(port, host, () => {
console.log('listening at https://%s:%s', host, port)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment