Node 8.4.0 has introduced the "http2" module as part of node core, which you can use if you launch node with --expose-http2.
When using it with koa, however, I get an error:
TypeError: Cannot set property statusMessage of #<Http2ServerResponse> which has only a getter
The error comes from /lib/response.js, line 88. HTTP/2 does not have status messages, so Node throws an error when you try to set one.
This is the code I'm using:
const http2 = require('http2');
const fs = require('fs');
const Koa = require('koa');
const Router = require('koa-router');
const app = new Koa();
const options = {
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.crt')
};
http2.createSecureServer(options, app.callback()).listen(3000);
const router = new Router();
router.get('/', (ctx) => ctx.body = "response");
app.use(router.routes());
Node 8.4.0 has introduced the "http2" module as part of node core, which you can use if you launch node with
--expose-http2.When using it with koa, however, I get an error:
The error comes from /lib/response.js, line 88. HTTP/2 does not have status messages, so Node throws an error when you try to set one.
This is the code I'm using: