Http2 not working with express

1.9k views Asked by At

I have server.js file where is some code

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

$ 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.). 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?

2

There are 2 answers

2
Shekspir On BEST ANSWER

Ok it wasn't http2 issue, just firefox doesn't want to open it.In chrome all works great on https://localhost:8080/.

0
Tom Rogers On

At time of writing this, there are known issues with using node-http2 with express, see here: https://github.com/molnarg/node-http2/issues/100