Skip to content

Commit 1e7ddb2

Browse files
giltayaraddaleax
authored andcommitted
doc: explain browser support of http/2 without SSL
Since browser support HTTP/2 only using SSL, the basic example given in the docs won't work if the client is a browser. Added a note to documentation explaining this and how to change the code to make browser support it. PR-URL: #14670 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent dbb9c37 commit 1e7ddb2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

doc/api/http2.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ server.on('stream', (stream, headers) => {
3939
server.listen(80);
4040
```
4141

42+
Note that the above example is an HTTP/2 server that does not support SSL.
43+
This is significant as most browsers support HTTP/2 only with SSL.
44+
To make the above server be able to serve content to browsers,
45+
replace `http2.createServer()` with
46+
`http2.createSecureServer({key: /* your SSL key */, cert: /* your SSL cert */})`.
47+
4248
The following illustrates an HTTP/2 client:
4349

4450
```js

0 commit comments

Comments
 (0)