|
const express = require('express'); |
|
const https = require('https'); |
|
const fs = require('fs'); |
|
const app = express(); |
|
|
|
const host = '0.0.0.0'; |
|
const port = 8080; |
|
|
|
|
|
const privateKey = fs.readFileSync('key.pem', 'utf8'); |
|
const certificate = fs.readFileSync('cert.pem', 'utf8'); |
|
|
|
const credentials = { key: privateKey, cert: certificate }; |
|
|
|
|
|
app.use((req, res, next) => { |
|
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin'); |
|
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp'); |
|
next(); |
|
}); |
|
|
|
|
|
app.use(express.static('.')); |
|
|
|
|
|
const httpsServer = https.createServer(credentials, app); |
|
|
|
httpsServer.listen(port, host, () => { |
|
console.log(`HTTPS server listening at https://${host}:${port}`); |
|
}); |
|
|