Skip to content

Commit 42d2eb3

Browse files
authored
fix(http): copy native response url to fetch response
1 parent aa52296 commit 42d2eb3

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

android/capacitor/src/main/assets/native-bridge.js

+8
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,14 @@ var nativeBridge = (function (exports) {
392392
headers: nativeResponse.headers,
393393
status: nativeResponse.status,
394394
});
395+
/*
396+
* copy url to response, `cordova-plugin-ionic` uses this url from the response
397+
* we need `Object.defineProperty` because url is an inherited getter on the Response
398+
* see: https://stackoverflow.com/a/57382543
399+
* */
400+
Object.defineProperty(response, 'url', {
401+
value: nativeResponse.url,
402+
});
395403
console.timeEnd(tag);
396404
return response;
397405
}

core/native-bridge.ts

+9
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,15 @@ const initBridge = (w: any): void => {
447447
status: nativeResponse.status,
448448
});
449449

450+
/*
451+
* copy url to response, `cordova-plugin-ionic` uses this url from the response
452+
* we need `Object.defineProperty` because url is an inherited getter on the Response
453+
* see: https://stackoverflow.com/a/57382543
454+
* */
455+
Object.defineProperty(response, 'url', {
456+
value: nativeResponse.url,
457+
});
458+
450459
console.timeEnd(tag);
451460
return response;
452461
} catch (error) {

ios/Capacitor/Capacitor/assets/native-bridge.js

+8
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,14 @@ var nativeBridge = (function (exports) {
392392
headers: nativeResponse.headers,
393393
status: nativeResponse.status,
394394
});
395+
/*
396+
* copy url to response, `cordova-plugin-ionic` uses this url from the response
397+
* we need `Object.defineProperty` because url is an inherited getter on the Response
398+
* see: https://stackoverflow.com/a/57382543
399+
* */
400+
Object.defineProperty(response, 'url', {
401+
value: nativeResponse.url,
402+
});
395403
console.timeEnd(tag);
396404
return response;
397405
}

0 commit comments

Comments
 (0)