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):
null
with something like https://acme.server.net
?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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With