File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed
android/capacitor/src/main/assets
ios/Capacitor/Capacitor/assets Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -497,6 +497,15 @@ var nativeBridge = (function (exports) {
497497 if ( doPatchHttp ) {
498498 // fetch patch
499499 window . fetch = async ( resource , options ) => {
500+ const headers = new Headers ( options === null || options === void 0 ? void 0 : options . headers ) ;
501+ const contentType = headers . get ( 'Content-Type' ) || headers . get ( 'content-type' ) ;
502+ if ( ( options === null || options === void 0 ? void 0 : options . body ) instanceof FormData &&
503+ ( contentType === null || contentType === void 0 ? void 0 : contentType . includes ( 'multipart/form-data' ) ) &&
504+ ! contentType . includes ( 'boundary' ) ) {
505+ headers . delete ( 'Content-Type' ) ;
506+ headers . delete ( 'content-type' ) ;
507+ options . headers = headers ;
508+ }
500509 const request = new Request ( resource , options ) ;
501510 if ( request . url . startsWith ( `${ cap . getServerUrl ( ) } /` ) ) {
502511 return win . CapacitorWebFetch ( resource , options ) ;
Original file line number Diff line number Diff line change @@ -543,6 +543,18 @@ const initBridge = (w: any): void => {
543543 resource : RequestInfo | URL ,
544544 options ?: RequestInit ,
545545 ) => {
546+ const headers = new Headers ( options ?. headers ) ;
547+ const contentType =
548+ headers . get ( 'Content-Type' ) || headers . get ( 'content-type' ) ;
549+ if (
550+ options ?. body instanceof FormData &&
551+ contentType ?. includes ( 'multipart/form-data' ) &&
552+ ! contentType . includes ( 'boundary' )
553+ ) {
554+ headers . delete ( 'Content-Type' ) ;
555+ headers . delete ( 'content-type' ) ;
556+ options . headers = headers ;
557+ }
546558 const request = new Request ( resource , options ) ;
547559 if ( request . url . startsWith ( `${ cap . getServerUrl ( ) } /` ) ) {
548560 return win . CapacitorWebFetch ( resource , options ) ;
Original file line number Diff line number Diff line change @@ -497,6 +497,15 @@ var nativeBridge = (function (exports) {
497497 if ( doPatchHttp ) {
498498 // fetch patch
499499 window . fetch = async ( resource , options ) => {
500+ const headers = new Headers ( options === null || options === void 0 ? void 0 : options . headers ) ;
501+ const contentType = headers . get ( 'Content-Type' ) || headers . get ( 'content-type' ) ;
502+ if ( ( options === null || options === void 0 ? void 0 : options . body ) instanceof FormData &&
503+ ( contentType === null || contentType === void 0 ? void 0 : contentType . includes ( 'multipart/form-data' ) ) &&
504+ ! contentType . includes ( 'boundary' ) ) {
505+ headers . delete ( 'Content-Type' ) ;
506+ headers . delete ( 'content-type' ) ;
507+ options . headers = headers ;
508+ }
500509 const request = new Request ( resource , options ) ;
501510 if ( request . url . startsWith ( `${ cap . getServerUrl ( ) } /` ) ) {
502511 return win . CapacitorWebFetch ( resource , options ) ;
You can’t perform that action at this time.
0 commit comments