@@ -865,10 +865,12 @@ export class CommonHttpClient {
865865 } else if ( action . type === 'redirect' ) {
866866 const fetchRequest =
867867 action . request ??
868- ( await this . generateFetchRequest ( {
869- path : newUrl . pathname ,
870- method : redirectPreservingMethod ? request . method : 'GET'
871- } ) ) ;
868+ (
869+ await this . generateFetchRequest ( {
870+ path : newUrl . pathname ,
871+ method : redirectPreservingMethod ? request . method : 'GET'
872+ } )
873+ ) [ 0 ] ;
872874 return this . performFetchRequest ( newUrl , fetchRequest , this . options . fetch ?? defaultFetch ) ;
873875 } else if ( action . type === 'externalRedirect' ) {
874876 const fetchRequest = action . request ?? {
@@ -900,7 +902,9 @@ export class CommonHttpClient {
900902 }
901903 }
902904
903- protected async generateFetchRequest ( request : CommonHttpClientRequest ) : Promise < CommonHttpClientFetchRequest > {
905+ protected async generateFetchRequest (
906+ request : CommonHttpClientRequest
907+ ) : Promise < [ CommonHttpClientFetchRequest , CommonHttpClientRequest ] > {
904908 try {
905909 request = await this . preprocessRequest ( request ) ;
906910 } catch ( e ) {
@@ -935,14 +939,17 @@ export class CommonHttpClient {
935939 ...otherRequestProps
936940 } = request ;
937941 const headers = this . cleanupHeaders ( requestHeaders ) ;
938- return {
939- ...otherRequestProps ,
940- headers,
941- cache : cache ?? 'default' ,
942- credentials : credentials ?? 'same-origin' ,
943- redirect : 'error' ,
944- body : this . getRequestBody ( request )
945- } ;
942+ return [
943+ {
944+ ...otherRequestProps ,
945+ headers,
946+ cache : cache ?? 'default' ,
947+ credentials : credentials ?? 'same-origin' ,
948+ redirect : 'error' ,
949+ body : this . getRequestBody ( request )
950+ } ,
951+ request
952+ ] ;
946953 }
947954
948955 protected async performFetchRequest (
@@ -1000,10 +1007,10 @@ export class CommonHttpClient {
10001007 */
10011008 protected async performRequest ( request : CommonHttpClientRequest ) : Promise < CommonHttpClientFetchResponse > {
10021009 this . logDeprecationWarningIfNecessary ( request ) ;
1003- const fetchRequest = await this . generateFetchRequest ( request ) ;
1010+ const [ fetchRequest , preprocessedRequest ] = await this . generateFetchRequest ( request ) ;
10041011 let url ;
10051012 try {
1006- url = this . buildUrl ( request ) ;
1013+ url = this . buildUrl ( preprocessedRequest ) ;
10071014 } catch ( e ) {
10081015 throw new this . options . errorClass (
10091016 new URL ( request . path , this . options . baseUrl ) ,
0 commit comments