Skip to content

Commit b20487f

Browse files
committed
docs(get-started): use secure http2 server
Closes #98
1 parent 92b1658 commit b20487f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

website/src/pages/get-started.mdx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,18 @@ import { schema } from './previous-step';
9999
const handler = createHandler({ schema });
100100

101101
// Create an HTTP/2 server using the handler on `/graphql/stream`
102-
const server = http2.createServer((req, res) => {
103-
if (req.url.startsWith('/graphql/stream')) {
104-
return handler(req, res);
105-
}
106-
res.writeHead(404).end();
107-
});
102+
const server = http2.createSecureServer(
103+
{
104+
key: fs.readFileSync('localhost-privkey.pem'),
105+
cert: fs.readFileSync('localhost-cert.pem'),
106+
},
107+
(req, res) => {
108+
if (req.url.startsWith('/graphql/stream')) {
109+
return handler(req, res);
110+
}
111+
return res.writeHead(404).end();
112+
},
113+
);
108114

109115
server.listen(4000);
110116
console.log('Listening to port 4000');

0 commit comments

Comments
 (0)