Browse Source

fix(gui-v2): use relative path as base url to avoid issue when using proxy

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3528/head
Pranav C 2 years ago
parent
commit
a828a4be43
  1. 5
      packages/nc-gui/composables/useApi/index.ts
  2. 3
      packages/nc-gui/composables/useGlobal/state.ts
  3. 1
      packages/nc-gui/lib/constants.ts

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

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

3
packages/nc-gui/composables/useGlobal/state.ts

@ -2,6 +2,7 @@ import { usePreferredLanguages, useStorage } from '@vueuse/core'
import { useJwt } from '@vueuse/integrations/useJwt'
import type { JwtPayload } from 'jwt-decode'
import type { AppInfo, State, StoredState } from './types'
import { BASE_URL } from '~/lib'
import { computed, ref, toRefs, useCounter, useNuxtApp, useTimestamp } from '#imports'
import type { User } from '~/lib'
@ -77,7 +78,7 @@ export function useGlobalState(storageKey = 'nocodb-gui-v2'): State {
})
const appInfo = ref<AppInfo>({
ncSiteUrl: process.env.NC_BACKEND_URL || (process.env.NODE_ENV === 'production' ? '..' : 'http://localhost:8080'),
ncSiteUrl: BASE_URL,
authType: 'jwt',
connectToExternalDB: false,
defaultLimit: 0,

1
packages/nc-gui/lib/constants.ts

@ -1,3 +1,4 @@
export const NOCO = 'noco'
export const USER_PROJECT_ROLES = 'user_project_roles'
export const SYSTEM_COLUMNS = ['id', 'title', 'created_at', 'updated_at']
export const BASE_URL = process.env.NC_BACKEND_URL || (process.env.NODE_ENV === 'production' ? '..' : 'http://localhost:8080')

Loading…
Cancel
Save