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({
196
196
broadcaster,
197
197
// replace the placeholders
198
198
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
199
201
});
200
202
` ` `
201
203
Original file line number Diff line number Diff line change @@ -136,9 +136,15 @@ export class Websocket {
136
136
if ( channel . name . startsWith ( 'private-' ) || channel . name . startsWith ( 'presence-' ) ) {
137
137
console . log ( `Sending auth request for channel ${ channel . name } ` )
138
138
139
+ if ( this . options . bearerToken ) {
140
+ this . options . auth . headers [ 'Authorization' ] = 'Bearer ' + this . options . bearerToken ;
141
+ }
142
+
139
143
axios . post ( this . options . authEndpoint , {
140
144
socket_id : this . getSocketId ( ) ,
141
145
channel_name : channel . name ,
146
+ } , {
147
+ headers : this . options . auth . headers || { }
142
148
} ) . then ( ( response : AxiosResponse ) => {
143
149
console . log ( `Subscribing to channels ${ channel . name } ` )
144
150
You can’t perform that action at this time.
0 commit comments