【发布时间】:2015-08-29 07:12:07
【问题描述】:
我有 server.js 文件,其中有一些代码
var express = require('express')
var app = express()
var fs = require('fs');
app.get('/', function (req, res) {
res.send('hello, http2!')
})
var options = {
key: fs.readFileSync('./localhost.key'),
cert: fs.readFileSync('./localhost.crt')
};
require('http2').createServer(options, app).listen(8080);
之后我在 shell 中运行
$ node server.js
服务器正在等待,但我无法打开它。我试过http://localhost:8080 和https://localhost:8080(我知道这是对的。)。但是什么都没有发生,浏览器中没有错误没有响应,我做错了什么?还有.key和.crt的文件不是我生成的,我只是复制的,会不会有问题?
【问题讨论】:
标签: node.js express https server http2