I am running both backend and expo locally. On the backend there’s an integration with an API that requires a connection from a static IP address, for which I use a VPN connection.
The problem is that when I turn on the VPN server, I can’t open the app from my mobile. It tries to connect and fails. Has anyone had such an issue, or does anybody have an idea how to handle this?
One possibility is to use the backend that’s deployed on a server, but if I need to make a change, I will need to wait for the deployment to finish before continuing with work.
When you do
expo-cli start to spin up your local environment, do you see difference in “Expo DevTools is running at http://…” address and then after Metro Bundler is up, at expo address: “expo://…”?
If those change once you turn up VPN, there are few environment variables that you can pass to expo-cli:
REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.2 << set this ip address to your computers local IP address, which your mobile can reach. It might automatically bind to VPN address, so overriding like this helps. This needs to be actual IP address.
EXPO_DEVTOOLS_LISTEN_ADDRESS=0.0.0.0 << giving this environment variable DevTools environment tries to listen all interfaces (0.0.0.0). It might not be what you need, but worth a try.
Another option you could do, is to reconfigure your VPN to not be default gateway, instead just make it as route for that one single IP. A bit more complex thing to explain, as it depends on whole environment how it is done. Might be good to ask from your VPN providers how to narrow it down a bit, or what can be done for it.
Expo is running on the correct local IP: exp://192.168.1.103:19000. However, the app won’t load when the VPN is turned on.
EXPO_DEVTOOLS_LISTEN_ADDRESS=0.0.0.0 doesn’t make a difference either.
I can use the tunnel connection, however LAN is much faster and preffered, so if there’s any other ideas I might try, then please share.
No further ideas right now. Would need a bit better understanding of your development setup (network diagram maybe mostly). Backend and it’s needs for VPN/static IP/API shouldn’t affect what happens in Expo client, or it should be possible to configure to be narrow enough to not interfere.
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.