[英]Http2 not working with express
我有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-http2與express一起使用存在已知問題,請參見此處: https : //github.com/molnarg/node-http2/issues/100
好的,這不是http2問題,只是firefox不想打開它。在chrome中,所有方法都可以在https:// localhost:8080 /上很好地工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.