Skip to content

Commit

Permalink
Update get-started.mdx
Browse files Browse the repository at this point in the history
change to createSecureServer
  • Loading branch information
comerc authored Apr 11, 2024
1 parent 92b1658 commit c1896b7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions website/src/pages/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,17 @@ import { schema } from './previous-step';
// Create the GraphQL over SSE handler
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);
// Create a HTTP/2 server using the handler on `/graphql/stream`
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()
}
res.writeHead(404).end();
});
);

server.listen(4000);
console.log('Listening to port 4000');
Expand Down

0 comments on commit c1896b7

Please sign in to comment.