Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am facing a very peculiar issue, when using Ionic 3 in iOS, I am trying to connect to a different domain [ddd.com], and since Ionic 3 uses WebKit, it changes the hostname to localhost:8080 in iOS.

This created a CORS issue, I was able to fix it by adding Allow-Control-Allow-Origin: http//localhost:8080 and Access-Control-Allow-Credentials: true.

Though this seems to work it had one issue, it never works the "first time" i.e when the app is downloaded and opened for the very first time. But it works when the app is killed and re-opened.

Any clue to un-wrap this tangly dangly mystery would be much appreciated.

  • Krishna Sagar
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
213 views
Welcome To Ask or Share your Answers For Others

1 Answer

Ionic3 use WKWebview where it enforces security for Ajax request. In 2 ways it can be rectified.

First solution: Use UIWebview instead of WKWebView. But these solution costs the performance of the App.

Second Solution Instead of angular HTTP call, Use native HTTP call. Use this plugin for easy implementation.

https://github.com/sneas/ionic-native-http-connection-backend


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...