App Transport Security blocks ajax calls


#1

Hi, I’ve written a simple vue app that performs an ajax call to
http://jsonplaceholder.typicode.com/posts

If I start the app with
npm run watch:ios
and perform the ajax call the console output is

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app’s Info.plist file.

I’ve changed the Info.plist under
ios/app/App_Resources/iOS/Info.plist
to

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true />
<dict>

but this does not any effect. If I build the app with xcode an run the app, the xcode console shows the response of the ajax request correctly.

Any help?

Thanks, Markus


#2

Did you try a clean build?


#3

Today I’ve created a new demo project with:

$ npm install -g @vue/cli @vue/cli-init
$ vue init nativescript-vue/vue-cli-template <project-name>
$ cd <project-name>
$ npm install

Visit the app with

npm run watch:ios

The app is running. Now I added

<key>NSAppTransportSecurity</key>
    <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
    </dict>

to the file /template/app/App_Resources/iOS/Info.plist

When I perform

npm run clean

and then

npm run watch:ios

the app performs the http call. That solves the problem for me.
Thank you