Skip to content

Instantly share code, notes, and snippets.

@retyui
Created Aug 15, 2018
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@retyui 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