@@ -71,7 +71,7 @@ Run the following command to start it:
71
71
72
72
.. code-block :: terminal
73
73
74
- $ JWT_KEY ='aVerySecretKey' ADDR ='localhost:3000' ALLOW_ANONYMOUS=1 CORS_ALLOWED_ORIGINS=* ./mercure
74
+ $ ./mercure --jwt-key ='aVerySecretKey' --addr ='localhost:3000' --allow-anonymous --cors-allowed-origins='*'
75
75
76
76
.. note ::
77
77
@@ -94,7 +94,7 @@ The preferred way to configure the MercureBundle is using
94
94
Set the URL of your hub as the value of the ``MERCURE_PUBLISH_URL `` env var.
95
95
The ``.env `` file of your project has been updated by the Flex recipe to
96
96
provide example values.
97
- Set it to the URL of the Mercure Hub (``http://localhost:3000/hub `` by default).
97
+ Set it to the URL of the Mercure Hub (``http://localhost:3000/.well-known/mercure `` by default).
98
98
99
99
In addition, the Symfony application must bear a `JSON Web Token `_ (JWT)
100
100
to the Mercure Hub to be authorized to publish updates.
@@ -189,7 +189,7 @@ Subscribing to updates in JavaScript is straightforward:
189
189
190
190
.. code-block :: javascript
191
191
192
- const eventSource = new EventSource (' http://localhost:3000/hub ?topic=' + encodeURIComponent (' http://example.com/books/1' ));
192
+ const eventSource = new EventSource (' http://localhost:3000/.well-known/mercure ?topic=' + encodeURIComponent (' http://example.com/books/1' ));
193
193
eventSource .onmessage = event => {
194
194
// Will be called every time an update is published by the server
195
195
console .log (JSON .parse (event .data ));
@@ -201,7 +201,7 @@ and to use URI Templates as patterns:
201
201
.. code-block :: javascript
202
202
203
203
// URL is a built-in JavaScript class to manipulate URLs
204
- const url = new URL (' http://localhost:3000/hub ' );
204
+ const url = new URL (' http://localhost:3000/.well-known/mercure ' );
205
205
url .searchParams .append (' topic' , ' http://example.com/books/1' );
206
206
// Subscribe to updates of several Book resources
207
207
url .searchParams .append (' topic' , ' http://example.com/books/2' );
@@ -295,7 +295,7 @@ by using the ``AbstractController::addLink`` helper method::
295
295
// This parameter is automatically created by the MercureBundle
296
296
$hubUrl = $this->getParameter('mercure.default_hub');
297
297
298
- // Link: <http://localhost:3000/hub >; rel="mercure"
298
+ // Link: <http://localhost:3000/.well-known/mercure >; rel="mercure"
299
299
$this->addLink($request, new Link('mercure', $hubUrl));
300
300
301
301
return $this->json([
@@ -311,7 +311,7 @@ and to subscribe to it:
311
311
.. code-block :: javascript
312
312
313
313
// Fetch the original resource served by the Symfony web API
314
- fetch (' /books/1' ) // Has Link: <http://localhost:3000/hub >; rel="mercure"
314
+ fetch (' /books/1' ) // Has Link: <http://localhost:3000/.well-known/mercure >; rel="mercure"
315
315
.then (response => {
316
316
// Extract the hub URL from the Link header
317
317
const hubUrl = response .headers .get (' Link' ).match (/ <([^ >] + )>;\s + rel=(?:mercure| "[^ "] * mercure[^ "] * ")/ )[1 ];
@@ -420,7 +420,7 @@ And here is the controller::
420
420
$response = $this->json(['@id' => '/demo/books/1', 'availability' => 'https://schema.org/InStock']);
421
421
$response->headers->set(
422
422
'set-cookie',
423
- sprintf('mercureAuthorization=%s; path=/hub ; secure; httponly; SameSite=strict', $token)
423
+ sprintf('mercureAuthorization=%s; path=/.well-known/mercure ; secure; httponly; SameSite=strict', $token)
424
424
);
425
425
426
426
return $response;
@@ -460,7 +460,7 @@ Then, reference this service in the bundle configuration:
460
460
mercure :
461
461
hubs :
462
462
default :
463
- url : https://mercure-hub.example.com/hub
463
+ url : https://mercure-hub.example.com/.well-known/mercure
464
464
jwt_provider : App\Mercure\MyJwtProvider
465
465
466
466
.. code-block :: xml
@@ -470,7 +470,7 @@ Then, reference this service in the bundle configuration:
470
470
<config >
471
471
<hub
472
472
name =" default"
473
- url =" https://mercure-hub.example.com/hub "
473
+ url =" https://mercure-hub.example.com/.well-known/mercure "
474
474
jwt-provider =" App\Mercure\MyJwtProvider"
475
475
/>
476
476
</config >
@@ -483,7 +483,7 @@ Then, reference this service in the bundle configuration:
483
483
$container->loadFromExtension('mercure', [
484
484
'hubs' => [
485
485
'default' => [
486
- 'url' => 'https://mercure-hub.example.com/hub ',
486
+ 'url' => 'https://mercure-hub.example.com/.well-known/mercure ',
487
487
'jwt_provider' => MyJwtProvider::class,
488
488
],
489
489
],
0 commit comments