I started learning React Native a few weeks ago and I've been trying to create a mobile app of my website. The only problem is, on Android and only on Android, network requests that contain the Authorization header don't go through. I'm using Axios for network requests. This is an example of one of the requests. The function is called in componentDidMount.
axios.get('https://exampleurl.com', {headers: {
'Authorization': 'Bearer ' + value}})
.then(response => {
console.log(response);
Alert.alert("There is a response");
this.setState({userData: response.data.data[0]});
})
.catch((error) => {
Alert.alert("There is an error", error.message);
that.setState({accessToken: ''});
});
The response I get is that no access token is sent. Yes I'm sure that value is not null. The code works on IoS and in the browser. Funny thing is the call passes and works OK if the debugger is turned on. Is there any reason why only Android doesn't work?
Is there something on the server side that needs to be configured to receive Android requests? The server is hosted on Amazon S3. Is there something maybe on my side that needs to be configured? All other network requests work in Axios (the ones without an Authorization header).
Thank you in advance!