diff --git a/packages/nc-gui/composables/useSharedFormViewStore.ts b/packages/nc-gui/composables/useSharedFormViewStore.ts index 69fcb5db23..32413b57f5 100644 --- a/packages/nc-gui/composables/useSharedFormViewStore.ts +++ b/packages/nc-gui/composables/useSharedFormViewStore.ts @@ -395,9 +395,24 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share const pk = extractPkFromRow(newRecord, meta.value?.columns as ColumnType[]) if (pk && isValidRedirectUrl.value) { - const url = sharedFormView.value!.redirect_url!.replace('{record_id}', pk) - window.location.href = url - window.location.reload() + const redirectUrl = sharedFormView.value!.redirect_url!.replace('{record_id}', pk) + + // Create an anchor element to parse the URL + const anchor = document.createElement('a') + anchor.href = redirectUrl + + // Check if the redirect URL has the same host as the current page + const isSameHost = anchor.host === window.location.host + + if (isSameHost) { + // Use pushState for internal links + window.history.pushState({}, 'Redirect', redirectUrl) + // Reload the page + window.location.reload() + } else { + // For external links, use window.location.href + window.location.href = redirectUrl + } } else { submitted.value = true progress.value = false