Skip to content

Instantly share code, notes, and snippets.

@retyui
Created August 15, 2018 12:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retyui/c94b432cca8dae5f15c5578c2bd77f64 to your computer and use it in GitHub Desktop.
Save retyui/c94b432cca8dae5f15c5578c2bd77f64 to your computer and use it in GitHub Desktop.
proxy React Native bandler to other compouter

I wokr on Linux and how I can test on IPhone?

This server.js I run on MacOS

Then all changes when I do on linux automatically apply on simulator on MacOS

Run

On Linux

react-native run-andriod && react-native start

On MacOS

node server.js && react-native run-ios
const http = require('http');
const httpProxy = require('http-proxy');

const PORT = 8081;
const target = {
  host: '10.0.0.158', // change to Linux computer IP in local network
  port: 8081
};
const proxy = new httpProxy.createProxyServer({target});
const proxyServer = http.createServer((req, res) => proxy.web(req, res));

// Listen to the upgrade event and proxy the
// WebSocket requests as well.
proxyServer.on('upgrade', (req, socket, head) => proxy.ws(req, socket, head));

proxyServer.listen(PORT);

console.log(`Proxy server listen ${PORT} port`);
console.log(`${target.host}:${target.port} => localhost:${PORT}`);
@retyui
Copy link
Author

retyui commented Aug 15, 2018

All functions remote debug, hot/live reload WORK!

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