File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,8 @@ window.Echo = new Echo({
196196 broadcaster,
197197 // replace the placeholders
198198 host: 'wss://{api-ip}.execute-api.{region}.amazonaws.com/{stage}',
199+ authEndpoint: '{auth-url}/broadcasting/auth', // Optional: Use if you have a separate authentication endpoint
200+ bearerToken: '{token}', // Optional: Use if you need a Bearer Token for authentication
199201});
200202` ` `
201203
Original file line number Diff line number Diff line change @@ -136,9 +136,15 @@ export class Websocket {
136136 if ( channel . name . startsWith ( 'private-' ) || channel . name . startsWith ( 'presence-' ) ) {
137137 console . log ( `Sending auth request for channel ${ channel . name } ` )
138138
139+ if ( this . options . bearerToken ) {
140+ this . options . auth . headers [ 'Authorization' ] = 'Bearer ' + this . options . bearerToken ;
141+ }
142+
139143 axios . post ( this . options . authEndpoint , {
140144 socket_id : this . getSocketId ( ) ,
141145 channel_name : channel . name ,
146+ } , {
147+ headers : this . options . auth . headers || { }
142148 } ) . then ( ( response : AxiosResponse ) => {
143149 console . log ( `Subscribing to channels ${ channel . name } ` )
144150
You can’t perform that action at this time.
0 commit comments