我刚刚设置了我的本地https服务器。但是,当我访问我的网站https://localhost:3001
或任何类似/home
或/ projects
的网页时,该网页都无法呈现。有人可以帮忙吗?这是我的代码:
var https = require('https');
var fs = require('fs');
var https_port = 3001;
var options = {
key: fs.readFileSync('./security/keys/localhost.key'),
cert: fs.readFileSync('./security/keys/localhost.crt')
};
var a = https.createServer(options, function (req, res) {
res.writeHead(200);
console.log('https server works!); //this prints out properly
}).listen(https_port);
答案 0 :(得分:0)
您应该使用路由器告诉您的服务器如何处理/home
或/projects
等路径。
var router = require('router');
router.get('/home', function(req, res){
res.send('This is home')
}