Skip to content

Enabling the https protocol #946

Answered by rschristian
mike-lischke asked this question in Q&A
Discussion options

You must be logged in to vote

It's less than ideal naming, but the --http2 flag is in all reality a https flag. createSecureServer returns a tls.Server instance and, through its options, supports downgrading clients that are not able to support http2:

export async function createHttp2Server(options = {}) {
const host = process.env.HOST || 'localhost';
const { key, cert } = await devcert.certificateFor(host);
const server = createSecureServer({
key,
cert,
allowHTTP1: true,
...options
});
return server;
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mike-lischke
Comment options

@rschristian
Comment options

Answer selected by mike-lischke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants