Skip to content

Commit 0c53c6f

Browse files
hfossliandrewsardone
authored andcommitted
Notes about app transport security
The error message wasn't very helpful. I didn't understand the problem until I debugged the `RCTJavaScriptLoader`. So this might be to help for others. Squashed commits by @andrewsardone into @hfossli’s [original commit][oc]: [oc]: andrewsardone/react-native@39fa5ca - Expand App Transport Security docs w/ localhost tip - Tweak ATS error note in EmbeddedAppIOS docs - Per @satya164’s [recommendation][r], using the exact copy he recommended. [r]: facebook/react-native#5290 (comment)
1 parent 5ac848c commit 0c53c6f

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

docs/EmbeddedAppIOS.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,28 @@ In root directory, we need to start React Native development server.
161161

162162
This command will start up a React Native development server within our CocoaPods dependency to build our bundled script. The `--root` option indicates the root of your React Native apps – this will be our `ReactComponents` directory containing the single `index.ios.js` file. This running server will package up the `index.ios.bundle` file accessible via `http://localhost:8081/index.ios.bundle`.
163163

164+
## Update App Transport Security
165+
166+
On iOS 9 and above the app won't be a able to connect over http to localhost unless specifically told so. See this thread for alternatives and instructions: http://stackoverflow.com/questions/31254725/transport-security-has-blocked-a-cleartext-http.
167+
168+
It is recommended that you add an App Transport Security exception for `localhost` in your app's `Info.plist` file:
169+
170+
```xml
171+
<key>NSAppTransportSecurity</key>
172+
<dict>
173+
<key>NSExceptionDomains</key>
174+
<dict>
175+
<key>localhost</key>
176+
<dict>
177+
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
178+
<true/>
179+
</dict>
180+
</dict>
181+
</dict>
182+
```
183+
184+
If you don't do this, you will see the error - `Could not connect to development server.` when connecting to your server over http.
185+
164186
## Compile And Run
165187

166188
Now compile and run your app. You shall now see your React Native app running inside of the `ReactView`.

0 commit comments

Comments
 (0)