Nativescript iOS Simulator Laravel API Error: The certificate for this server is invalid

This took me a bit to find an answer so I figured I'd add it in here to hopefully help others.

Here's the error when you try to call your API in Nativescript on iOS

The certificate for this server is invalid. You might be connecting to a server that is pretending to be "localtest.test" which could put your confidential information at risk. 

/Users/YOUR_USERNAME/Library/Application Support/Herd/config/valet/CA/LaravelValetVASelfSigned.pem

Then in the simulator, go to Settings -> General -> About -> Certificate Trust Settings

In finder drag and drop the certificate into the simulator and it will be added to the trusted list.

You might need to back out to settings home, then back in to see it enabled

Now in your App_Resources\iOS\info.plist add


<key>NSAppTransportSecurity</key>

<dict>

<key>NSAllowsArbitraryLoads</key>

<true/>

<key>NSExceptionDomains</key>

<dict>

<key>tripclok.test</key>

<dict>

<key>NSExceptionAllowsInsecureHTTPLoads</key>

<true/>

<key>NSIncludesSubdomains</key>

<true/>

<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>

<true/>

</dict>

</dict>

</dict>

ns clean

ns run ios

Should be good now

Ready to Start?

Let's Build Something Amazing Together

Ready to bring your vision to life? We specialize in creating stunning websites, mobile apps, and digital experiences that make an impact.

Accepting new clients
Free consultation
15+ years experience