Skip to content

Commit b251a08

Browse files
committed
Add axios socket header
1 parent b1447b7 commit b251a08

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

frontend/src/api/Api.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import axios from 'axios/index';
22
import Storage from '@/services/Storage';
33
import { EventEmitter, TOKEN_EXPIRED_EVENT } from '@/services/EventEmitter';
44
import { UNAUTHENTICATED } from '@/api/ErrorCodes';
5+
import { getSocketId } from '@/services/Pusher';
56

67
class Api {
78
constructor(apiUrl, authHeaderName = 'Authorization', authHeaderPrefix = 'Bearer') {
@@ -16,6 +17,10 @@ class Api {
1617
config.headers[authHeaderName] = `${authHeaderPrefix} ${Storage.getToken()}`;
1718
}
1819

20+
if (getSocketId()) {
21+
config.headers['X-Socket-ID'] = getSocketId();
22+
}
23+
1924
return config;
2025
},
2126
error => Promise.reject(error)

frontend/src/services/Pusher.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ if (Storage.hasToken()) {
2222

2323

2424
export const pusher = new Pusher(process.env.VUE_APP_PUSHER_APP_KEY, config);
25+
26+
export const getSocketId = () => {
27+
return pusher.connection.socket_id;
28+
};

0 commit comments

Comments
 (0)