Browse Source

fix: avoid overwriting baseurl for refresh token api call

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

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

@ -11,12 +11,9 @@ export function createApiInstance<SecurityDataType = any>({
const config = useRuntimeConfig() const config = useRuntimeConfig()
const baseURL = config.public.ncBackendUrl || _baseUrl const baseURL = config.public.ncBackendUrl || _baseUrl
return addAxiosInterceptors( return addAxiosInterceptors(
new Api<SecurityDataType>( new Api<SecurityDataType>({
{
baseURL, baseURL,
}, }),
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 let refreshTokenPromise: Promise<string> | null = null
export function addAxiosInterceptors(api: Api<any>, baseURL?: string) { export function addAxiosInterceptors(api: Api<any>) {
const state = useGlobal() const state = useGlobal()
const router = useRouter() const router = useRouter()
const route = router.currentRoute const route = router.currentRoute
@ -98,8 +98,7 @@ export function addAxiosInterceptors(api: Api<any>, baseURL?: string) {
// Try request again with new token // Try request again with new token
return api.instance return api.instance
.post('/auth/token/refresh', null, { .post('/auth/token/refresh', null, {
withCredentials: true, withCredentials: true
baseURL: baseURL ?? './',
}) })
.then((token) => { .then((token) => {
// New request with new token // New request with new token

Loading…
Cancel
Save