简体   繁体   English

Http2无法使用快递

[英]Http2 not working with express

I have server.js file where is some code 我有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);

After that I run in shell 之后,我在shell中运行

$ node server.js

And server is waiting, but I can't open it. 服务器正在等待,但是我无法打开它。 I tried http://localhost:8080 and https://localhost:8080 (I know that this is one is right one.). 我尝试了http:// localhost:8080https:// localhost:8080 (我知道这是对的。)。 But nothing is going on, no errors no response in browser, what am I doing wrong? 但是没有任何反应,没有错误,浏览器没有响应,我在做什么错? Also .key and .crt files not generated by me, I just copied it, can this be a problem? 另外,我不是复制我生成的.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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM