mirror of
https://github.com/freqtrade/frequi.git
synced 2024-09-20 09:31:10 +00:00
Fix bug with token refresh
This commit is contained in:
parent
c5eadc3d3d
commit
53c4641e8a
|
@ -1,11 +1,9 @@
|
|||
import axios from 'axios';
|
||||
import userService from './userService';
|
||||
|
||||
export const apiBase = '/api/v1';
|
||||
|
||||
export const api = axios.create({
|
||||
baseURL: apiBase,
|
||||
timeout: 1000,
|
||||
baseURL: userService.apiBase,
|
||||
timeout: 2000,
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
|
@ -43,11 +41,11 @@ api.interceptors.response.use(
|
|||
export function setBaseUrl(baseURL: string) {
|
||||
if (baseURL === null) {
|
||||
// Reset to "local" baseurl
|
||||
api.defaults.baseURL = apiBase;
|
||||
} else if (!baseURL.endsWith(apiBase)) {
|
||||
api.defaults.baseURL = `${baseURL}${apiBase}`;
|
||||
api.defaults.baseURL = userService.apiBase;
|
||||
} else if (!baseURL.endsWith(userService.apiBase)) {
|
||||
api.defaults.baseURL = `${baseURL}${userService.apiBase}`;
|
||||
} else {
|
||||
api.defaults.baseURL = `${baseURL}`;
|
||||
api.defaults.baseURL = `${baseURL}${userService.apiBase}`;
|
||||
}
|
||||
// Do some more testing here ?
|
||||
}
|
||||
|
|
|
@ -3,8 +3,10 @@ import axios from 'axios';
|
|||
const AUTH_REF_TOKEN = 'auth_ref_token';
|
||||
const AUTH_ACCESS_TOKEN = 'auth_access_token';
|
||||
const AUTH_API_URL = 'auth_api_url';
|
||||
const apiBase = '/api/v1';
|
||||
|
||||
export default {
|
||||
apiBase,
|
||||
AUTH_API_URL,
|
||||
setAPIUrl(apiurl) {
|
||||
localStorage.setItem(AUTH_API_URL, JSON.stringify(apiurl));
|
||||
|
@ -52,7 +54,7 @@ export default {
|
|||
console.log(apiurl);
|
||||
axios
|
||||
.post(
|
||||
`${this.getAPIUrl()}/token/refresh`,
|
||||
`${this.getAPIUrl()}/${apiBase}/token/refresh`,
|
||||
{},
|
||||
{
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
|
|
Loading…
Reference in New Issue
Block a user