Browse Source

fix: base url correction

pull/7444/head
Pranav C 7 months ago
parent
commit
f1d850a8c1
  1. 13
      packages/nc-gui/composables/useApi/index.ts
  2. 4
      packages/nc-gui/composables/useApi/interceptors.ts

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

@ -6,14 +6,17 @@ import { addAxiosInterceptors } from './interceptors'
import { BASE_FALLBACK_URL, createEventHook, extractSdkResponseErrorMsg, ref, unref, useCounter, useNuxtApp } from '#imports'
export function createApiInstance<SecurityDataType = any>({
baseURL = BASE_FALLBACK_URL,
baseURL: _baseUrl = BASE_FALLBACK_URL,
}: CreateApiOptions = {}): Api<SecurityDataType> {
const config = useRuntimeConfig()
const baseURL = config.public.ncBackendUrl || _baseUrl
return addAxiosInterceptors(
new Api<SecurityDataType>({
baseURL: config.public.ncBackendUrl || baseURL,
}),
new Api<SecurityDataType>(
{
baseURL,
},
baseUrl,
),
)
}

4
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>) {
export function addAxiosInterceptors(api: Api<any>, baseURL?: string) {
const state = useGlobal()
const router = useRouter()
const route = router.currentRoute
@ -99,7 +99,7 @@ export function addAxiosInterceptors(api: Api<any>) {
return api.instance
.post('/auth/token/refresh', null, {
withCredentials: true,
baseURL: location.pathname,
baseURL: baseURL ?? './',
})
.then((token) => {
// New request with new token

Loading…
Cancel
Save