Skip to content

Commit dd369ad

Browse files
committed
add authorization header if included
1 parent e7ca7c8 commit dd369ad

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

js-src/Websocket.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)