Skip to content

Commit 56731d9

Browse files
cipolleschizoontek
authored andcommitted
Derive iOS inspector URL scheme from bundle URL for HTTPS support (facebook#55871)
Summary: Pull Request resolved: facebook#55871 ## Summary: Use the bundle URL's scheme (http or https) when constructing inspector device URLs and open-debugger URLs in `RCTInspectorDevServerHelper`, instead of hardcoding `http://`. This allows the inspector and debugger to work correctly when the dev server is accessed over HTTPS. ## Changelog: [IOS][CHANGED] - Derive inspector and debugger URL scheme from bundle URL to support HTTPS dev servers ## Test Plan: Verified that `getInspectorDeviceUrl` and `openDebugger` now use the bundle URL's scheme, falling back to `http` when no scheme is available. ## Facebook: Applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+007+atod-ios-inspector-https.patch Reviewed By: cortinico Differential Revision: D95037969 fbshipit-source-id: 0e6729c2b91827655f4093dec890ad086e42facf
1 parent b332d96 commit 56731d9

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

packages/react-native/React/DevSupport/RCTInspectorDevServerHelper.mm

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,15 @@
112112
NSString *escapedInspectorDeviceId = [getInspectorDeviceId()
113113
stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
114114

115-
return [NSURL
116-
URLWithString:[NSString stringWithFormat:@"http://%@/inspector/device?name=%@&app=%@&device=%@&profiling=%@",
117-
getServerHost(bundleURL),
118-
escapedDeviceName,
119-
escapedAppName,
120-
escapedInspectorDeviceId,
121-
isProfilingBuild ? @"true" : @"false"]];
115+
NSString *scheme = [bundleURL scheme] != nullptr ? [bundleURL scheme] : @"http";
116+
return
117+
[NSURL URLWithString:[NSString stringWithFormat:@"%@://%@/inspector/device?name=%@&app=%@&device=%@&profiling=%@",
118+
scheme,
119+
getServerHost(bundleURL),
120+
escapedDeviceName,
121+
escapedAppName,
122+
escapedInspectorDeviceId,
123+
isProfilingBuild ? @"true" : @"false"]];
122124
}
123125

124126
@implementation RCTInspectorDevServerHelper
@@ -150,7 +152,9 @@ + (void)openDebugger:(NSURL *)bundleURL withErrorMessage:(NSString *)errorMessag
150152
NSString *escapedInspectorDeviceId = [getInspectorDeviceId()
151153
stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
152154

153-
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@/open-debugger?device=%@",
155+
NSString *scheme = [bundleURL scheme] != nullptr ? [bundleURL scheme] : @"http";
156+
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@/open-debugger?device=%@",
157+
scheme,
154158
getServerHost(bundleURL),
155159
escapedInspectorDeviceId]];
156160
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

0 commit comments

Comments
 (0)