Browse Source
Merge pull request #1095 from colinin/fix-signalr-token
🐛 fix(signalr): fixed invalid token after token refresh
pull/1105/head
yx lin
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
8 additions and
6 deletions
-
apps/vben5/packages/@abp/signalr/src/hooks/useSignalR.ts
|
|
|
@ -34,12 +34,14 @@ export function useSignalR() { |
|
|
|
}: SignalROptions) { |
|
|
|
const httpOptions: IHttpConnectionOptions = {}; |
|
|
|
if (useAccessToken) { |
|
|
|
const accessStore = useAccessStore(); |
|
|
|
const token = accessStore.accessToken; |
|
|
|
if (token) { |
|
|
|
httpOptions.accessTokenFactory = () => |
|
|
|
token.startsWith('Bearer ') ? token.slice(7) : token; |
|
|
|
} |
|
|
|
httpOptions.accessTokenFactory = () => { |
|
|
|
const accessStore = useAccessStore(); |
|
|
|
const token = accessStore.accessToken; |
|
|
|
if (!token) { |
|
|
|
return ''; |
|
|
|
} |
|
|
|
return token.startsWith('Bearer ') ? token.slice(7) : token; |
|
|
|
}; |
|
|
|
} |
|
|
|
const connectionBuilder = new HubConnectionBuilder() |
|
|
|
.withUrl(serverUrl, httpOptions) |
|
|
|
|