From 0e0838448a2dfc873333f58bed45a3b78cc663b7 Mon Sep 17 00:00:00 2001 From: Cedric van Putten Date: Mon, 11 Mar 2024 03:48:49 -0700 Subject: [PATCH] fix(dev-middleware): allow inspector proxy to fetch sourcemaps on lan 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: [GENERAL][FIXED] Allow Inspector proxy to inline source maps on LAN connections Pull Request resolved: https://github.com/facebook/react-native/pull/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 --- packages/dev-middleware/src/inspector-proxy/Device.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/dev-middleware/src/inspector-proxy/Device.js b/packages/dev-middleware/src/inspector-proxy/Device.js index 26befc0b118..455a89fd09f 100644 --- a/packages/dev-middleware/src/inspector-proxy/Device.js +++ b/packages/dev-middleware/src/inspector-proxy/Device.js @@ -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 { - 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) {