我有位于http上的节点快速服务器。 该服务器代理对另一个仅接受https的目标的请求。
我尝试使用https.createServer,但它确实可以工作。
问题是我如何将http请求快速表达为https。
//route to get the projects list
app.get("/getprojects", (req, res) => {
var projects = ["project1", "project2", "project3"];
res.send({ projects });
});
//error handling
app.use(function(req, res, next) {
res.status(404).send("Sorry can't find that!");
});
https
.createServer(
{
key: fs.readFileSync("./cert/server.key"),
cert: fs.readFileSync("./cert/server.cert"),
},
app
)
.listen(port, () => console.log(`HTTPS server is running on port ${port}!`));