fix: enhance deep link handling in insomniaFetch function in main (#9977)

This commit is contained in:
Bingbing authored and GitHub committed 2026-05-28 09:04:00 +00:00
1 parent 9c5ae2e307
commit e2878299c1
3 files changed
+10 -5

No files matched your search

@@ -13,9 +13,11 @@ export async function insomniaFetch<T = void>({
origin,
headers,
timeout = INSOMNIA_FETCH_TIME_OUT,
onDeepLink,
}: FetchConfig & {
// It's not used at all, should be removed?
retries?: number;
onDeepLink?: (uri: string) => void;
}): Promise<T> {
const config: RequestInit = {
method,
@@ -39,8 +41,8 @@ export async function insomniaFetch<T = void>({
try {
const response = await fetch((origin || getApiBaseURL()) + path, config);
const uri = response.headers.get('x-insomnia-command');
if (uri) {
window.main.openDeepLink(uri);
if (uri && onDeepLink) {
onDeepLink(uri);
}
const isJson = response.headers.get('content-type')?.includes('application/json') || path.match(/\.json$/);
if (!response.ok) {
+1 -1
View File
@@ -38,7 +38,7 @@ initServices(window._dataServices);
// Remove the global services reference after initialization to improve security by preventing unintended access from the global scope.
delete window._dataServices;
configureFetch(options => insomniaFetch({ ...options }));
configureFetch(options => insomniaFetch({ ...options, onDeepLink: (uri: string) => window.main.openDeepLink(uri) }));
await initPlugins();
+5 -2
View File
@@ -58,7 +58,10 @@ initializeSentry();
registerInsomniaProtocols();
configureFetch(options => insomniaFetch({ ...options }));
let openDeepLinkUrl = async (url: string) => {
console.warn('[main] openDeepLinkUrl function not initialized yet, cannot open URL:', url);
};
configureFetch(options => insomniaFetch({ ...options, onDeepLink: (uri: string) => openDeepLinkUrl(uri) }));
// Handle potential auto-update
if (checkIfRestartNeeded()) {
@@ -245,7 +248,7 @@ const _launchApp = async () => {
});
window = windowUtils.createWindowsAndReturnMain();
const openDeepLinkUrl = async (url: string) => {
openDeepLinkUrl = async (url: string) => {
console.log('[main] Open Deep Link URL', url);
window = windowUtils.createWindowsAndReturnMain();
if (window) {