|
|
@ -3,14 +3,16 @@ import { Api } from 'nocodb-sdk' |
|
|
|
import type { Ref } from 'vue' |
|
|
|
import type { Ref } from 'vue' |
|
|
|
import type { CreateApiOptions, UseApiProps, UseApiReturn } from './types' |
|
|
|
import type { CreateApiOptions, UseApiProps, UseApiReturn } from './types' |
|
|
|
import { addAxiosInterceptors } from './interceptors' |
|
|
|
import { addAxiosInterceptors } from './interceptors' |
|
|
|
import { BASE_URL, createEventHook, extractSdkResponseErrorMsg, ref, unref, useCounter, useGlobal, useNuxtApp } from '#imports' |
|
|
|
import { BASE_FALLBACK_URL, createEventHook, extractSdkResponseErrorMsg, ref, unref, useCounter, useNuxtApp } from '#imports' |
|
|
|
|
|
|
|
|
|
|
|
export function createApiInstance<SecurityDataType = any>({ baseURL = BASE_URL }: CreateApiOptions = {}): Api<SecurityDataType> { |
|
|
|
export function createApiInstance<SecurityDataType = any>({ |
|
|
|
const { appInfo } = $(useGlobal()) |
|
|
|
baseURL = BASE_FALLBACK_URL, |
|
|
|
|
|
|
|
}: CreateApiOptions = {}): Api<SecurityDataType> { |
|
|
|
|
|
|
|
const config = useRuntimeConfig() |
|
|
|
|
|
|
|
|
|
|
|
return addAxiosInterceptors( |
|
|
|
return addAxiosInterceptors( |
|
|
|
new Api<SecurityDataType>({ |
|
|
|
new Api<SecurityDataType>({ |
|
|
|
baseURL: baseURL ?? appInfo.ncSiteUrl, |
|
|
|
baseURL: config.public.ncBackendUrl || baseURL, |
|
|
|
}), |
|
|
|
}), |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|