node.js server and HTTP/2 (2.0) with express.js

var express = require('express');
var app = express();

app.get("https://stackoverflow.com/", function (req, res) {
  res.send('hello, http2!');
});

var options = {
  key: fs.readFileSync('./example/localhost.key'),
  cert: fs.readFileSync('./example/localhost.crt')
};

require('http2').createServer(options, app).listen(8080);

EDIT

This code snippet was taken from a conversation on Github.

Leave a Comment