Created
August 21, 2020 09:20
-
-
Save syuji-higa/5b44fa5985af2bd91c6466f4c976dbfb to your computer and use it in GitHub Desktop.
Node.js - https local server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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