Skip to content

Instantly share code, notes, and snippets.

@x0000ff
Last active December 23, 2018 02:05
Show Gist options
  • Save x0000ff/7392920e37e6583602bf2bd7d2a2f070 to your computer and use it in GitHub Desktop.
Save x0000ff/7392920e37e6583602bf2bd7d2a2f070 to your computer and use it in GitHub Desktop.
App Transport Security :: Disable for localhost

If you see this error "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." in Xcode console:

load failed with error Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection., NSErrorFailingURLStringKey=http://localhost/BLAH-BLAH-BLAH, NSErrorFailingURLKey=http://localhost:3000/brands, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <F7630F1E-0BA5-4EBC-9CDA-351A5842F84D>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <F7630F1E-0BA5-4EBC-9CDA-351A5842F84D>.<1>, NSUnderlyingError=0x6000001a9860 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}} [-1022]
Error: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

Add to your Info.plist:

<key>NSAppTransportSecurity</key>    
<dict>
    <key>NSAllowsLocalNetworking</key>
    <true/>
</dict>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment