Browse Source

fix: avoid overwriting baseurl for refresh token api call

pull/7444/head
Pranav C 10 months ago
parent
commit
bcb550cdfd
  1. 9
      packages/nc-gui/composables/useApi/index.ts
  2. 5
      packages/nc-gui/composables/useApi/interceptors.ts

9
packages/nc-gui/composables/useApi/index.ts

@ -11,12 +11,9 @@ export function createApiInstance<SecurityDataType = any>({
const config = useRuntimeConfig()
const baseURL = config.public.ncBackendUrl || _baseUrl
return addAxiosInterceptors(
new Api<SecurityDataType>(
{
baseURL,
},
baseUrl,
),
new Api<SecurityDataType>({
baseURL,
}),
)
}

5
packages/nc-gui/composables/useApi/interceptors.ts

@ -5,7 +5,7 @@ const DbNotFoundMsg = 'Database config not found'
let refreshTokenPromise: Promise<string> | null = null
export function addAxiosInterceptors(api: Api<any>, baseURL?: string) {
export function addAxiosInterceptors(api: Api<any>) {
const state = useGlobal()
const router = useRouter()
const route = router.currentRoute
@ -98,8 +98,7 @@ export function addAxiosInterceptors(api: Api<any>, baseURL?: string) {
// Try request again with new token
return api.instance
.post('/auth/token/refresh', null, {
withCredentials: true,
baseURL: baseURL ?? './',
withCredentials: true
})
.then((token) => {
// New request with new token

Loading…
Cancel
Save