Skip to content

Commit

Permalink
fix(dev-middleware): allow inspector proxy to fetch sourcemaps on lan…
Browse files Browse the repository at this point in the history
… connections (#43307)

Summary:
The inspector proxy is inlining source maps on `Debugger.scriptParsed` CDP events. The inlining prevents Chrome DevTools from downloading this remotely, as that's not supported in newer versions anymore.

The current implementation locks this inlining mechanism to just `localhost` and/or `127.0.0.1` addresses, making it incompatible with LAN or tunnel device connections.

This PR removes that limitation to allow source map inlining on these LAN and tunnel connections.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[GENERAL][FIXED] Allow Inspector proxy to inline source maps on LAN connections

Pull Request resolved: #43307

Test Plan:
- See added test
- Start Metro and connect a device over LAN, open the chrome devtools

Reviewed By: huntie

Differential Revision: D54485247

Pulled By: robhogan

fbshipit-source-id: 6fcb0c6dd762d2f0a013497ba0a1126095b9130b
  • Loading branch information
byCedric authored and facebook-github-bot committed Mar 11, 2024
1 parent e2157f0 commit 3dee6d3
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions packages/dev-middleware/src/inspector-proxy/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,10 +758,6 @@ export default class Device {
// Fetch text, raising an exception if the text could not be fetched,
// or is too large.
async #fetchText(url: URL): Promise<string> {
if (!['localhost', '127.0.0.1'].includes(url.hostname)) {
throw new Error('remote fetches not permitted');
}

// $FlowFixMe[incompatible-call] Suppress arvr node-fetch flow error
const response = await fetch(url);
if (!response.ok) {
Expand Down

0 comments on commit 3dee6d3

Please sign in to comment.