From 6f4d753299acb74784825e16bfb8e66f1c1abdf1 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 9 Dec 2024 15:28:11 +0530 Subject: [PATCH] fix: shared url and dashboard url corrections (#9999) --- .../dlg/share-and-collaborate/ShareBase.vue | 14 ++------------ .../dlg/share-and-collaborate/SharePage.vue | 12 ++---------- packages/nocodb/src/run/cloud.ts | 10 ++++++++++ 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/packages/nc-gui/components/dlg/share-and-collaborate/ShareBase.vue b/packages/nc-gui/components/dlg/share-and-collaborate/ShareBase.vue index d171ce9a11..c8690be865 100644 --- a/packages/nc-gui/components/dlg/share-and-collaborate/ShareBase.vue +++ b/packages/nc-gui/components/dlg/share-and-collaborate/ShareBase.vue @@ -18,22 +18,12 @@ const sharedBase = ref(null) const { base } = storeToRefs(useBase()) -const { getBaseUrl, appInfo } = useGlobal() - -const workspaceStore = useWorkspace() +const { appInfo } = useGlobal() const url = computed(() => { if (!sharedBase.value || !sharedBase.value.uuid) return '' - // get base url for workspace - const baseUrl = getBaseUrl(workspaceStore.activeWorkspaceId) - - let dashboardUrl1 = dashboardUrl.value - - if (baseUrl) { - dashboardUrl1 = `${baseUrl}${appInfo.value?.dashboardPath}` - } - return encodeURI(`${dashboardUrl1}#/base/${sharedBase.value.uuid}`) + return encodeURI(`${dashboardUrl.value}#/base/${sharedBase.value.uuid}`) }) const loadBase = async () => { diff --git a/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue b/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue index f644852665..8fac6d85dd 100644 --- a/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue +++ b/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue @@ -4,7 +4,7 @@ import { ViewTypes } from 'nocodb-sdk' const { view: _view, $api } = useSmartsheetStoreOrThrow() const { $e } = useNuxtApp() -const { getBaseUrl, appInfo } = useGlobal() +const { appInfo } = useGlobal() const { dashboardUrl } = useDashboard() @@ -203,15 +203,7 @@ function sharedViewUrl() { viewType = 'view' } - // get base url for workspace - const baseUrl = getBaseUrl(workspaceStore.activeWorkspaceId) - - let dashboardUrl1 = dashboardUrl.value - if (baseUrl) { - dashboardUrl1 = `${baseUrl}${appInfo.value?.dashboardPath}` - } - - return `${encodeURI(`${dashboardUrl1}#/nc/${viewType}/${activeView.value.uuid}${surveyMode.value ? '/survey' : ''}`)}${ + return `${encodeURI(`${dashboardUrl.value}#/nc/${viewType}/${activeView.value.uuid}${surveyMode.value ? '/survey' : ''}`)}${ viewStore.preFillFormSearchParams && formPreFill.value.preFillEnabled ? `?${viewStore.preFillFormSearchParams}` : '' }` } diff --git a/packages/nocodb/src/run/cloud.ts b/packages/nocodb/src/run/cloud.ts index bfcc4174a4..14518b23a8 100644 --- a/packages/nocodb/src/run/cloud.ts +++ b/packages/nocodb/src/run/cloud.ts @@ -15,6 +15,16 @@ server.use( process.env.NC_DASHBOARD_URL ?? '/dashboard', express.static(path.join(__dirname, 'nc-gui')), ); + +// if NC_DASHBOARD_URL is not set to /dashboard, then redirect '/dashboard' +// to the path set in NC_DASHBOARD_URL +if (!/^\/?dashboard\/?$/.test(process.env.NC_DASHBOARD_URL)) { + server.use('/dashboard', (_, res) => { + // redirect to NC_DASHBOARD_URL path + res.redirect(process.env.NC_DASHBOARD_URL); + }); +} + server.set('view engine', 'ejs'); (async () => {