路由更新,crosrToken接口增加
This commit is contained in:
@@ -382,17 +382,24 @@ class BoxApi {
|
||||
}
|
||||
|
||||
private _authHeader(token: string | null = null): object {
|
||||
// const access_token = token === "" ? this.token : token;
|
||||
const alertToken = localStorage.getItem(`alertToken`) || token || this.token || "" || "";
|
||||
const accessToken = token || this.token || localStorage.getItem('alertToken') || "";
|
||||
return {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'Authorization': `Bearer ${alertToken}`,
|
||||
// 'Cookie': `jwt=${access_token}`
|
||||
'Authorization': `Bearer ${accessToken}`,
|
||||
// 'X-CSRFToken': this.getCsrfToken()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
private getCsrfToken(): string {
|
||||
const cookie = document.cookie.split(';').find(cookie => cookie.trim().startsWith('csrftoken='));
|
||||
if (cookie) {
|
||||
return cookie.split('=')[1];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
private _boxAddr() {
|
||||
return window.location.host.replace(/:\d+/, "");
|
||||
|
||||
Reference in New Issue
Block a user