8000 Symfony: Two topics on one page · Issue #82 · symfony/mercure-bundle · GitHub
[go: up one dir, main page]

Skip to content

Symfony: Two topics on one page #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
7cookies opened this issue Jul 17, 2023 · 3 comments
Closed

Symfony: Two topics on one page #82

7cookies opened this issue Jul 17, 2023 · 3 comments

Comments

@7cookies
Copy link

Hi,

I'm using two topics on my symfony-project:

/user/notification/{userid} -> Send notifications to user (flash messages, statusupdates)
/user/messenger/{userid} -> Messages from other users

Both (private) topics were created by diefferent symfony-services.
At the client-side I'm using different stimulus-controllers:

"eventEndpoint": mercure(notificationChannelName, { subscribe: notificationChannelName })
"eventEndpoint": mercure(messengerChannelName, { subscribe: messengerChannelName})

Both topics are working perfect.
But when I'm using both on the same page, I get this error:
An exception has been thrown during the rendering of a template ("The "mercureAuthorization" cookie for the "default hub" has already been set. You cannot set it two times during the same request.").

I have no idea how to fix this.

I think I can set the cookie by myself:
$authorization->setCookie($request, ['/user/notification/{userid}','/user/messenger/{userid}']);

But the mercure-twig-helper still tries to set the cookie. -> Error again.

What can I do?

@ThomasLandauer
Copy link

See symfony/symfony-docs#20574

javiereguiluz added a commit to symfony/symfony-docs that referenced this issue Jan 21, 2025
This PR was merged into the 6.4 branch.

Discussion
----------

[Mercure] Adding hint for multiple topics

Page: https://symfony.com/doc/6.4/mercure.html#subscribing

Closes #20574 Closes symfony/mercure-bundle#71 Closes symfony/mercure-bundle#82

Info is taken from #20574 (comment)

Commits
-------

3dca32e [Mercure] Adding hint for multiple topics
@ThomasLandauer
Copy link

IMO, this can be closed by symfony/symfony-docs#20580

@chalasr
Copy link
Member
chalasr commented Jan 21, 2025

Thanks @ThomasLandauer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0