I'm a new user of this platform and I'm trying to integrate Mercure into Symfony by following the documentation: https://symfony.com/blog/symfony-gets-real-time-push-capabilities . Once all the steps in the console are followed of chrome to the response of the Publisher class an error is generated:
net :: ERR_ABORTED 406.
Could you help me to understand how to make this bundle work?
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mercure\Publisher;
use Symfony\Component\Mercure\Update;
class PublishController
{
public function __invoke(Publisher $publisher)
{
$update = new Update(
'http://example.com/books/1',
json_encode(['status' => 'OutOfStock'])
);
// The Publisher service is an invokable object
$publisher($update);
}
}
const es = new EventSource('https://www.davidecpr.online/hub?topic=' + encodeURIComponent('http://example.com/books/1'));
es.onmessage = e => {
// Will be called every time an update is published by the server
console.log(JSON.parse(e.data));
};
The .env variable is set like this: 'MERCURE_PUBLISH_URL' => 'http://www.davidecpr.online:3000/hub'