Drmario901's avatar

How can I authenticate Laravel Reverb private channels using JWT (Tymon JWTAuth) in Laravel 12?

Hi everyone, I need help understanding how to authenticate private channels in Laravel 12 when using Laravel Reverb together with Tymon JWTAuth.

My project is API-only (no sessions, no cookies, no web middleware). All authentication is done through JWT (Bearer token).

I want to know:

How can I authenticate '/broadcasting/auth' using JWT so that private channels work correctly in Laravel 12?

If anyone has an example, recommended approach, or knows how Laravel 12 expects broadcasting authentication to work without sessions, I’d really appreciate your guidance.

Thanks in advance!

1 like
1 reply
itsmill3rtime's avatar

you need to set the auth headers. here is my echo setup for connecting to reverb:

 configureEcho({
    broadcaster: "reverb",
    key: config.public.reverbAppKey,
    wsHost: config.public.reverbHost,
    wsPort: config.public.reverbPort,
    wssPort: config.public.reverbPort,
    //force TLS if browser is https
    forceTLS: (window.location.protocol === 'https:'),
    // forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
    enabledTransports: ['ws', 'wss'],
    authEndpoint: config.public.apiBase + '/broadcasting/auth',
    auth: {
      headers: {
        Authorization: "Bearer " + token.value
      },
    }
  });
2 likes

Please or to participate in this conversation.