Skip to content

Commit 3ff8635

Browse files
cipolleschimeta-codesync[bot]
authored andcommitted
Apply custom dev support headers to iOS HTTP requests
Summary: ## Summary: Apply custom HTTP headers from `RCTDevSupportHttpHeaders` to all HTTP requests sent through `RCTHTTPRequestHandler`. This ensures that auth tokens and other custom headers configured via the dev support header API are included in network requests made by the networking module (e.g. `fetch()`). ## Changelog: [IOS][CHANGED] - Apply custom dev support HTTP headers to RCTHTTPRequestHandler requests ## Test Plan: Verified that the request is copied to a mutable request and headers are applied via `RCTDevSupportHttpHeaders` before creating the data task. ## Facebook: Applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+006+atod-ios-http-handler.patch Differential Revision: D95037920
1 parent 05a3851 commit 3ff8635

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/react-native/Libraries/Network/RCTHTTPRequestHandler.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#import <mutex>
1111

12+
#import <React/RCTDevSupportHttpHeaders.h>
1213
#import <React/RCTNetworking.h>
1314
#import <ReactCommon/RCTTurboModule.h>
1415

@@ -99,7 +100,9 @@ - (NSURLSessionDataTask *)sendRequest:(NSURLRequest *)request withDelegate:(id<R
99100
valueOptions:NSPointerFunctionsStrongMemory
100101
capacity:0];
101102
}
102-
NSURLSessionDataTask *task = [_session dataTaskWithRequest:request];
103+
NSMutableURLRequest *mutableRequest = [request mutableCopy];
104+
[[RCTDevSupportHttpHeaders sharedInstance] applyHeadersToRequest:mutableRequest];
105+
NSURLSessionDataTask *task = [_session dataTaskWithRequest:mutableRequest];
103106
[_delegates setObject:delegate forKey:task];
104107
[task resume];
105108
return task;

0 commit comments

Comments
 (0)