So thanks to @Mukeyii I found the answer (for a Mac and an iPhone at least) on this page
Here are the steps :
- On your Node app, you need to give the port and the ip you'll be listening the app, for example :
const app = require('./app'); // app is made with express.js
app.set('port', 80);
const server = app.listen(app.get('port'), '0.0.0.0', () => {
console.log(`Express running → PORT ${server.address().port}`);
});
Strangely, I wanted to put the 127.0.0.1
ip but it didn't work. 0.0.0.0
worked for me so I put that one.
On the /private/etc/hosts
file, add the line 0.0.0.0 any.url.you.wish
, save and test on a browser on your computer that when you start your app (dev mode) and you type the url any.url.you.wish
, you go on your app.
Download SquidMan and open it, let it install what it wants to install.
In SquidMan > Preferences, set the port in the General tab (for me: 80)
On the Client tab, set a new ip: the ip address of the iOS mobile device. To get it, you need to click on the i
in front of your WiFi connected network.
On the Template tab, add a comment on the line http_access deny to_localhost
and add these two lines :
# hosts file
hosts_file /private/etc/hosts
- Save the Preferences and Start Squid
- Get the IP Address of the Mac in System Preferences > Network
- Configure the Proxy on the iPhone (port + ip) at the bottom of the same view described in 5.
That's it ! Read more infos in this url: http://egalo.com/2012/05/29/testing-mac-web-site-using-local-hostname-on-mobile-device/