기타/WEB
Node https 적용
hu6r1s
2022. 8. 28. 15:12
const express = require('express');
const fs = require('fs');
const options = {
key: fs.readFileSync('./rootca.key'),
cert: fs.readFileSync('./rootca.crt')
};
const app = express();
// Default route for server status
app.get('/', (req, res) => { res.json({ message: `Server is running on port ${req.secure ? HTTPS_PORT : HTTP_PORT}` }); });
// Create an HTTP server.
http.createServer(app).listen(HTTP_PORT);
// Create an HTTPS server.
https.createServer(options, app).listen(HTTPS_PORT);