I have the following code...
const PORT = process.env.PORT || 5000;
const app = new Koa();
...
app.listen(PORT)
This works great both locally and in Heroku. So now I want to use Http2 so I change to the following...
const server = http2.createSecureServer(
{
"key": fs.readFileSync('./server-key.pem'),
"cert": fs.readFileSync('./server-cert.pem')
},
app.callback()
)
server.listen(PORT);
This works ok locally, however, when I upload to Heroku I get...
2021-06-24T00:43:00.383108+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=my-app.herokuapp.com request_id=604f4a2c-8dd2-4cfa-9cf2-3cce5ef76070 fwd="..." dyno=web.1 connect=0ms service=1ms status=503 bytes=0 protocol=https
So how do I get http2 working with Node, Koa, and Heroku?
Per this article on devcenter.heroku.com, Heroku does not yet support http/2.
You can use an add-on like https://elements.heroku.com/addons/expeditedwaf or you can use cloudflare. If you decide to use cloudflare, make sure you add a SSL certificate between cloudflare and heroku.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With