diff --git a/android/capacitor/src/main/assets/native-bridge.js b/android/capacitor/src/main/assets/native-bridge.js index e30c8a4ec..58d694077 100644 --- a/android/capacitor/src/main/assets/native-bridge.js +++ b/android/capacitor/src/main/assets/native-bridge.js @@ -425,15 +425,14 @@ var nativeBridge = (function (exports) { // fetch patch window.fetch = async (resource, options) => { const request = new Request(resource, options); - if (!(request.url.startsWith('http:') || - request.url.startsWith('https:'))) { + if (request.url.startsWith(`${cap.getServerUrl()}/`)) { return win.CapacitorWebFetch(resource, options); } const tag = `CapacitorHttp fetch ${Date.now()} ${resource}`; console.time(tag); try { const { body, method } = request; - const { data: requestData, type, headers } = await convertBody(body || undefined); + const { data: requestData, type, headers, } = await convertBody(body || undefined); const optionHeaders = Object.fromEntries(request.headers.entries()); const nativeResponse = await cap.nativePromise('CapacitorHttp', 'request', { url: request.url, diff --git a/core/native-bridge.ts b/core/native-bridge.ts index 4a6ceb7b3..fc466eac7 100644 --- a/core/native-bridge.ts +++ b/core/native-bridge.ts @@ -473,13 +473,7 @@ const initBridge = (w: any): void => { options?: RequestInit, ) => { const request = new Request(resource, options); - - if ( - !( - request.url.startsWith('http:') || - request.url.startsWith('https:') - ) - ) { + if (request.url.startsWith(`${cap.getServerUrl()}/`)) { return win.CapacitorWebFetch(resource, options); } diff --git a/ios/Capacitor/Capacitor/assets/native-bridge.js b/ios/Capacitor/Capacitor/assets/native-bridge.js index e30c8a4ec..58d694077 100644 --- a/ios/Capacitor/Capacitor/assets/native-bridge.js +++ b/ios/Capacitor/Capacitor/assets/native-bridge.js @@ -425,15 +425,14 @@ var nativeBridge = (function (exports) { // fetch patch window.fetch = async (resource, options) => { const request = new Request(resource, options); - if (!(request.url.startsWith('http:') || - request.url.startsWith('https:'))) { + if (request.url.startsWith(`${cap.getServerUrl()}/`)) { return win.CapacitorWebFetch(resource, options); } const tag = `CapacitorHttp fetch ${Date.now()} ${resource}`; console.time(tag); try { const { body, method } = request; - const { data: requestData, type, headers } = await convertBody(body || undefined); + const { data: requestData, type, headers, } = await convertBody(body || undefined); const optionHeaders = Object.fromEntries(request.headers.entries()); const nativeResponse = await cap.nativePromise('CapacitorHttp', 'request', { url: request.url,