Fix iOS inspector getServerHost to handle HTTPS correctly#55872
Closed
cipolleschi wants to merge 5 commits intofacebook:mainfrom
Closed
Fix iOS inspector getServerHost to handle HTTPS correctly#55872cipolleschi wants to merge 5 commits intofacebook:mainfrom
cipolleschi wants to merge 5 commits intofacebook:mainfrom
Conversation
|
@cipolleschi has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95038004. |
cortinico
approved these changes
Mar 3, 2026
Contributor
cortinico
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
6cc33d2 to
afdb609
Compare
added 3 commits
March 4, 2026 03:49
Summary: ## Summary: Derive the WebSocket scheme (ws/wss) and port from the dev server URL in `setUpReactDevTools.js` so React DevTools connections work correctly when the dev server is accessed over HTTPS. The Android `OkHttpClientProvider` and `WebSocketModule` changes from the original ATOD patch are intentionally omitted because these are production modules that cannot depend on the dev-only `DevSupportHttpClient` module due to Buck module boundaries. ## Changelog: [GENERAL][CHANGED] - Derive WebSocket scheme and port from dev server URL for React DevTools connections, supporting HTTPS dev servers ## Test Plan: Validated that the JS change correctly derives ws/wss scheme and port from the dev server URL, falling back to ws://host:8097 for local development. ## Facebook: Partially applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+004+atod-websocket.patch (Android OkHttpClientProvider and WebSocketModule changes omitted — they create an invalid Buck dependency from production modules to dev-only modules) Differential Revision: D95043354
Summary: ## Summary: Replace the blind application of dev headers on all WebSocket connections with a provider pattern that mirrors RCTHTTPRequestHandler's NSURLSessionConfigurationProvider. A custom `SRWebSocketProvider` block can be registered via `RCTSetCustomSRWebSocketProvider` to intercept WebSocket creation and selectively modify the request (e.g. injecting auth headers) for specific endpoints. If no provider is set, or if the provider returns nil, the default SRWebSocket creation logic is used. - Declare `SRWebSocketProvider` typedef and `RCTSetCustomSRWebSocketProvider` in RCTWebSocketModule.h - Implement the provider hook in RCTWebSocketModule.mm - Remove the previous blind `RCTDevSupportHttpHeaders` application ## Changelog: [IOS][CHANGED] - Add SRWebSocketProvider for selective WebSocket header injection ## Test Plan: Verified that the `SRWebSocketProvider` block is called when registered, and that returning nil falls back to the default SRWebSocket creation. When no provider is registered, behavior is unchanged from before. ## Facebook: Applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+005+atod-websocket-ios.patch Differential Revision: D95037876
Summary: ## Summary: Replace the blind application of dev headers on all HTTP requests with an interceptor pattern. A custom `RCTHTTPRequestInterceptor` block can be registered via `RCTSetCustomHTTPRequestInterceptor` to inspect and modify HTTP requests before they are sent. The interceptor returns a modified request to override, or nil to use the original request unchanged. This preserves the shared NSURLSession configuration (including meta-auth mTLS) while allowing selective per-request header injection. - Declare `RCTHTTPRequestInterceptor` typedef and `RCTSetCustomHTTPRequestInterceptor` in RCTHTTPRequestHandler.h - Implement the interceptor hook in RCTHTTPRequestHandler.mm - Remove the previous blind `RCTDevSupportHttpHeaders` application ## Changelog: [IOS][CHANGED] - Add RCTHTTPRequestInterceptor for selective HTTP request modification ## Test Plan: Verified that the RCTHTTPRequestInterceptor block is called when registered, and that returning nil leaves the original request unchanged. When no interceptor is registered, behavior is unchanged from before. ## Facebook: Applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+006+atod-ios-http-handler.patch Differential Revision: D95037920
cipolleschi
added a commit
to cipolleschi/react-native
that referenced
this pull request
Mar 4, 2026
…5872) Summary: ## Summary: Update `getServerHost()` in `RCTInspectorDevServerHelper` to properly handle HTTPS connections. When the bundle URL uses HTTPS, the port is omitted from the host string (the scheme implies 443). The explicit port from the URL takes priority, followed by the `RCT_METRO_PORT` environment variable, with 8081 as the default fallback for local development. ## Changelog: [IOS][FIXED] - Fix inspector server host resolution for HTTPS bundle URLs by omitting default port ## Test Plan: Verified that getServerHost returns: - `host:port` when an explicit port is in the URL - `host:envPort` when RCT_METRO_PORT is set - `host` (no port) when the scheme is https - `host:8081` as the default fallback ## Facebook: Applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+008+atod-ios-ws-fixes.patch Reviewed By: cortinico Differential Revision: D95038004
afdb609 to
bd17e02
Compare
cipolleschi
added a commit
to cipolleschi/react-native
that referenced
this pull request
Mar 4, 2026
…5872) Summary: Pull Request resolved: facebook#55872 ## Summary: Update `getServerHost()` in `RCTInspectorDevServerHelper` to properly handle HTTPS connections. When the bundle URL uses HTTPS, the port is omitted from the host string (the scheme implies 443). The explicit port from the URL takes priority, followed by the `RCT_METRO_PORT` environment variable, with 8081 as the default fallback for local development. ## Changelog: [IOS][FIXED] - Fix inspector server host resolution for HTTPS bundle URLs by omitting default port ## Test Plan: Verified that getServerHost returns: - `host:port` when an explicit port is in the URL - `host:envPort` when RCT_METRO_PORT is set - `host` (no port) when the scheme is https - `host:8081` as the default fallback ## Facebook: Applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+008+atod-ios-ws-fixes.patch Reviewed By: cortinico Differential Revision: D95038004
bd17e02 to
6f87a07
Compare
Summary: ## 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 Differential Revision: D95037969
6f87a07 to
add78c0
Compare
cipolleschi
added a commit
to cipolleschi/react-native
that referenced
this pull request
Mar 4, 2026
…5872) Summary: ## Summary: Update `getServerHost()` in `RCTInspectorDevServerHelper` to properly handle HTTPS connections. When the bundle URL uses HTTPS, the port is omitted from the host string (the scheme implies 443). The explicit port from the URL takes priority, followed by the `RCT_METRO_PORT` environment variable, with 8081 as the default fallback for local development. ## Changelog: [IOS][FIXED] - Fix inspector server host resolution for HTTPS bundle URLs by omitting default port ## Test Plan: Verified that getServerHost returns: - `host:port` when an explicit port is in the URL - `host:envPort` when RCT_METRO_PORT is set - `host` (no port) when the scheme is https - `host:8081` as the default fallback ## Facebook: Applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+008+atod-ios-ws-fixes.patch Reviewed By: cortinico Differential Revision: D95038004
cipolleschi
added a commit
to cipolleschi/react-native
that referenced
this pull request
Mar 4, 2026
…5872) Summary: Pull Request resolved: facebook#55872 ## Summary: Update `getServerHost()` in `RCTInspectorDevServerHelper` to properly handle HTTPS connections. When the bundle URL uses HTTPS, the port is omitted from the host string (the scheme implies 443). The explicit port from the URL takes priority, followed by the `RCT_METRO_PORT` environment variable, with 8081 as the default fallback for local development. ## Changelog: [IOS][FIXED] - Fix inspector server host resolution for HTTPS bundle URLs by omitting default port ## Test Plan: Verified that getServerHost returns: - `host:port` when an explicit port is in the URL - `host:envPort` when RCT_METRO_PORT is set - `host` (no port) when the scheme is https - `host:8081` as the default fallback ## Facebook: Applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+008+atod-ios-ws-fixes.patch Reviewed By: cortinico Differential Revision: D95038004
add78c0 to
2098260
Compare
…5872) Summary: Pull Request resolved: facebook#55872 ## Summary: Update `getServerHost()` in `RCTInspectorDevServerHelper` to properly handle HTTPS connections. When the bundle URL uses HTTPS, the port is omitted from the host string (the scheme implies 443). The explicit port from the URL takes priority, followed by the `RCT_METRO_PORT` environment variable, with 8081 as the default fallback for local development. ## Changelog: [IOS][FIXED] - Fix inspector server host resolution for HTTPS bundle URLs by omitting default port ## Test Plan: Verified that getServerHost returns: - `host:port` when an explicit port is in the URL - `host:envPort` when RCT_METRO_PORT is set - `host` (no port) when the scheme is https - `host:8081` as the default fallback ## Facebook: Applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+008+atod-ios-ws-fixes.patch Reviewed By: cortinico Differential Revision: D95038004
2098260 to
5994c8c
Compare
|
This pull request has been merged in 3582a8b. |
zoontek
pushed a commit
to zoontek/react-native
that referenced
this pull request
Mar 9, 2026
…5872) Summary: Pull Request resolved: facebook#55872 ## Summary: Update `getServerHost()` in `RCTInspectorDevServerHelper` to properly handle HTTPS connections. When the bundle URL uses HTTPS, the port is omitted from the host string (the scheme implies 443). The explicit port from the URL takes priority, followed by the `RCT_METRO_PORT` environment variable, with 8081 as the default fallback for local development. ## Changelog: [IOS][FIXED] - Fix inspector server host resolution for HTTPS bundle URLs by omitting default port ## Test Plan: Verified that getServerHost returns: - `host:port` when an explicit port is in the URL - `host:envPort` when RCT_METRO_PORT is set - `host` (no port) when the scheme is https - `host:8081` as the default fallback ## Facebook: Applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+008+atod-ios-ws-fixes.patch Reviewed By: cortinico Differential Revision: D95038004 fbshipit-source-id: 38b6f54b9e7f0346ef7ee4411099ef055769685b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Summary:
Update
getServerHost()inRCTInspectorDevServerHelperto properly handleHTTPS connections. When the bundle URL uses HTTPS, the port is omitted from the
host string (the scheme implies 443). The explicit port from the URL takes
priority, followed by the
RCT_METRO_PORTenvironment variable, with 8081as the default fallback for local development.
Changelog:
[IOS][FIXED] - Fix inspector server host resolution for HTTPS bundle URLs by omitting default port
Test Plan:
Verified that getServerHost returns:
host:portwhen an explicit port is in the URLhost:envPortwhen RCT_METRO_PORT is sethost(no port) when the scheme is httpshost:8081as the default fallbackFacebook:
Applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+008+atod-ios-ws-fixes.patch
Reviewed By: cortinico
Differential Revision: D95038004