So we are in development of an iPhone application (iOS 9+, not 8), where we are using WKWebView and local files to start the thing up. To get data into the app we are planning to use a secure service that will also handle authentication, and were thinking that CORS was the way to do this.
Loading files from the file system, however, sets the origin in the HTTP request to null
, which is not allowed when we also want to send cookies (for authentication).
So my question(s):
- Can we set an origin in WKWebView to overwrite the
null
with something likehttps://acme.server.net
? - What are other people (you) doing?
- Should we consider doing something else other than CORS? (JSONP is not an option).
1 Answers
Answers 1
You can create a local webserver on the iPhone and load your files from that. This way origin will not be null and you can use CORS to connect to your server.
I have found GCDWebServer to be easy to work with.
Personally I would rather use HTML5 AppCache or ServiceWorkers to create a local application cache without the need for CORS, but WKWebView does not support these and to my knowledge you are forced to use the webserver approach
0 comments:
Post a Comment