Skip to content

react native networking not working after updating xcode to 8.3.2 #14083

Closed
@alzalabany

Description

@alzalabany

Description

all of a sudden, all my applications are getting Newtwork request failed after i updated my xcode to 8.3.2,

Network request failed
TypeError: Network request failed

i tried changing values in /ios/[projectname]/info.plist but still getting same error, even when i'm calling https:// endpoints.

<key>NSAppTransportSecurity</key>
	<!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->
	<dict>
		<key>NSExceptionDomains</key>
		<dict>
			<key>localhost</key>
			<dict>
				<key>NSExceptionAllowsInsecureHTTPLoads</key>
				<true/>
			</dict>
		</dict>
	</dict>

Reproduction Steps and Sample Code

$ react-native init newProject && cd newProject && react-native run-ios

open index.ios.js and add test

            <Button title="fetch" onPress={async ()=>{
              const r = await fetch('http://localhost/ivf/system/settings');
              console.log(r);
            }}/>
            <Button title="fetchs" onPress={async ()=>{
              const r = await fetch('https://ivf.simpleinfroamtics.com/system/settings').catch(console.log);
              console.log(r);
            }}/>

by clicking on both links they both will fail with newtwok request failed.

i tried using xhr insteed

componentDidMount(){
var request = new XMLHttpRequest();
request.onreadystatechange = (e) => {
if (request.readyState !== 4) {
return;
}

if (request.status === 200) {
console.log('success', request.responseText);
} else {
console.warn('error');
}
};

request.open('GET', 'http://localhost/endpoint/');
request.send(); //will fail same error yet exactly same error.

how can we fix this ??? i already finished my whole app and i'm waitting to fix this so i can publish :(

List all the steps required to reproduce the issue you're reporting. These steps should be clear and concise.

  • React Native version: 0.44
  • Platform: IOS
  • Development Operating System: macOs xcode-8.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions