Skip to content

Commit 06e978a

Browse files
committed
update mercure doc to add clarification in authorization
1 parent 0635d10 commit 06e978a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mercure.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,16 @@ a JWT containing at least one target marking the update to the Hub.
362362

363363
To provide this JWT, the subscriber can use a cookie,
364364
or a ``Authorization`` HTTP header.
365-
Cookies are automatically sent by the browsers when opening an ``EventSource`` connection.
365+
Cookies are automatically sent by the browsers when opening an ``EventSource`` connection if the ``withCredentials`` attribute is set to ``true``.
366366
Using cookies is the most secure and preferred way when the client is a web browser.
367367
If the client is not a web browser, then using an authorization header is the way to go.
368368

369+
.. code-block:: javascript
370+
371+
const eventSource = new EventSource(hub, {
372+
withCredentials: true
373+
});
374+
369375
.. tip::
370376

371377
The native implementation of EventSource doesn't allow specifying headers.

0 commit comments

Comments
 (0)