Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to easily enable cross-origin-request for React/ReactNative metro / devtool server access #2591

Open
deckyfx opened this issue Feb 4, 2025 · 1 comment

Comments

@deckyfx
Copy link

deckyfx commented Feb 4, 2025

Describe the Feature

Background:

I have peculiar setups for developing React Native (RN), as I enjoy having remote coding.
My code is in a remote Linux machine, then I connect to it via SSH in vs-code on Windows, then I connect my Linux to an Android device with ADB.

I host the code on Linux so it has a better unix dev environment and builds speed, but I access it from Windows for ease of multi-tasking like browsing, etc, because of this, I can't run the app on Emulator as the AVD and Android-SDK are in Linux machine. that's why I connect it to real device.

Issues:

Prior to RN v0.77, there was no issue with this setup, but since v0.77 removed the console.log stream to metro and encouraged devs to use rn-dev-tools, now I have an issue as the rn-dev-tools opening chrome locally (on the Linux machine), and currently that dev tools is restricted to be used in localhost.

Solution

The solutions are pretty simple, just disable securityHeadersMiddleware so the metro can accept connections from any origin, but currently there is no easy way to do this, also may need to have a feature to easily get connected device id as the rn-dev-tool address has format

http://<host | localhost>:<port | 8081>/debugger-frontend/rn_fusebox.html?ws=%2Finspector%2Fdebug%3Fdevice%3D<device_id>%26page%3D1&sources.hide_add_folder=true

Decoded
http://<host | localhost>:<port | 8081>/debugger-frontend/rn_fusebox.html?ws=/inspector/debug?device=<device_id>&page=1&sources.hide_add_folder=true

Possible Implementations

For example, add keyboard shortcut to get dev tool addresses, port, and device_id connected

Related Issues

@liamjones
Copy link
Contributor

Recently, there's been some discussion in a similar vein on the discussions & proposals repo: react-native-community/discussions-and-proposals#819 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants