React Native application does not connect to Node server.js on my laptop

I'm developing an app in React Native, using expo.

I have a Node API.js running on my MacBook. Both my mobile when laptop are under same Wifi network.

In the app, I have an API call, pointing to the IP of my machine + port where the server is running:

import axios from 'axios';

const api = axios.create({
    baseURL: 'http://<IP da máquina>:3333'
});

export default api;

The API call is made at:

const response = await api.get('resource')

However, when I start the application, the data that should come from my Node server.js, are not loaded.

Trying to access the same endpoint in the mobile browser, I get the error:

ERR_ADDRESS_UNREACHABLE

I have tried several ways to solve the problem: - Disabled the Firewall of the machine - I checked if the router configuration 'AP isolation' was enabled, and it was not. - among other things.

Author: Vitor Rodrigues, 2020-03-29

1 answers

For security reasons, on newer Android and IOS systems, http requests are blocked because it is not a secure protocol and allows only https.

 0
Author: augusto1997, 2020-03-29 19:56:02