Common:Axios: set new header cookie 'x-docspace-address' for oauth2 service, update return value on onSuccess request
This commit is contained in:
parent
f5c2bd64db
commit
8dbfda6f2b
@ -1,4 +1,6 @@
|
||||
import axios from "axios";
|
||||
|
||||
import { setCookie } from "./";
|
||||
import combineUrl from "./combineUrl";
|
||||
import defaultConfig from "PUBLIC_DIR/scripts/config.json";
|
||||
|
||||
@ -26,6 +28,8 @@ class AxiosClient {
|
||||
};
|
||||
}
|
||||
|
||||
setCookie("x-docspace-address", origin, {}, true);
|
||||
|
||||
const lastKeySymbol = location.search.indexOf("&");
|
||||
const lastIndex =
|
||||
lastKeySymbol === -1 ? location.search.length : lastKeySymbol;
|
||||
@ -73,6 +77,9 @@ class AxiosClient {
|
||||
|
||||
const apiBaseURL = combineUrl(origin, proxyURL, apiPrefix);
|
||||
|
||||
if (!headers.cookie.includes(origin))
|
||||
headers.cookie = `${headers.cookie};x-docspace-address=${origin}`;
|
||||
|
||||
const axiosConfig = {
|
||||
baseURL: apiBaseURL,
|
||||
responseType: "json",
|
||||
@ -123,7 +130,9 @@ class AxiosClient {
|
||||
|
||||
if (response.request.responseType === "text") return response.data;
|
||||
|
||||
return response.data.response;
|
||||
return typeof response.data.response !== "undefined"
|
||||
? response.data.response
|
||||
: response.data;
|
||||
};
|
||||
|
||||
const onError = (error) => {
|
||||
|
Loading…
Reference in New Issue
Block a user