react-native-static-server icon indicating copy to clipboard operation
react-native-static-server copied to clipboard

Android - It is starting on 192.*.*.* and not on localhost

Open Noitidart opened this issue 6 years ago • 6 comments

Hi there,

On Android, I am trying to host a staic server on localhost, i have remote debugging enabled, but i also tried with it disabled.

Is there anyway to force it on localhost? Is this only happening cuz im in dev mode?

Noitidart avatar Feb 03 '18 22:02 Noitidart

Or any way to force it to use 127.0.0.1 because I am using this for oauth page on google and it only accept localhost or 127.0.0.1

Noitidart avatar Feb 03 '18 22:02 Noitidart

Did you find any solution about this issue @Noitidart ?

Regards

GregoryBabonaux avatar Feb 18 '18 17:02 GregoryBabonaux

@GregoryBabonaux no I couldnt find a solution. It was a major problem I was having and ended requesting approvals to completely changing my architecture to avoid a local server localhost. (Not being at localhost, caused some issues down the line.)

Noitidart avatar Feb 18 '18 18:02 Noitidart

Thanks for your feedback

I think the problem is this plugin need a real network to work properly. So it needs a DHCP who provide a real ip address, not a localhost / 127.0.0.1 of the device

I’ve the same issue when i want to run my app without wifi

Regards

GregoryBabonaux avatar Feb 18 '18 19:02 GregoryBabonaux

Check https://github.com/futurepress/react-native-static-server/blob/master/android/src/main/java/com/futurepress/staticserver/FPStaticServerModule.java#L31

Haven't tried it yet, but we got a localhost_only bool there ;)

xemasiv avatar Apr 11 '18 22:04 xemasiv

Check https://github.com/futurepress/react-native-static-server/blob/master/android/src/main/java/com/futurepress/staticserver/FPStaticServerModule.java#L31

Haven't tried it yet, but we got a localhost_only bool there ;)

I was facing the same issue and this lead me to the solution:

This parameter is taken from the options-parameter. If you start the server to be available inside the app only, it will use localhost, otherwise it has to search for an available IP address. So if you need localhost as Server-Url, you have to make it available only inside the app on Android (paramter localOnly)

thinkmobilede avatar May 24 '19 08:05 thinkmobilede