From b20487fcbf9a6b6ef29fdb62076533f64e272a32 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Mon, 22 Apr 2024 16:49:22 +0200 Subject: [PATCH] docs(get-started): use secure http2 server Closes #98 --- website/src/pages/get-started.mdx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/website/src/pages/get-started.mdx b/website/src/pages/get-started.mdx index 06b2162..6cdf965 100644 --- a/website/src/pages/get-started.mdx +++ b/website/src/pages/get-started.mdx @@ -99,12 +99,18 @@ import { schema } from './previous-step'; const handler = createHandler({ schema }); // Create an HTTP/2 server using the handler on `/graphql/stream` -const server = http2.createServer((req, res) => { - if (req.url.startsWith('/graphql/stream')) { - return handler(req, res); - } - res.writeHead(404).end(); -}); +const server = http2.createSecureServer( + { + key: fs.readFileSync('localhost-privkey.pem'), + cert: fs.readFileSync('localhost-cert.pem'), + }, + (req, res) => { + if (req.url.startsWith('/graphql/stream')) { + return handler(req, res); + } + return res.writeHead(404).end(); + }, +); server.listen(4000); console.log('Listening to port 4000');