Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6291] iOS: Cors issue in WKWebView (sdk 8.0.1)

GitHub Issuen/a
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labels8.0.1, 8.1.0.GA, 8.2.0.GA, 8.3.0, 9.0.0.RC, ios, webView
AssigneeVijay Singh


I'm testing an app with sdk 8.0.1 but the webview component has changed (now is WKWebView) and fails to load a SPA with AngularJS ngRoute navigation, showing a cors error: _Cross origin requests are only supported for HTTP_ The app works fine with sdk 7.4.1. I think the problem is the WkWebView is missing property allowFileAccessFromFileURLs which seems to solve Cors issues. *To Reproduce* 1 - Create a window containing a webview with url:'index.html' 2 - Create index.html file containing an AngularJS single page application with angular version 1.4.7 and ngRoute navigation, for example:
    <meta charset="utf-8">
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular-route.js"></script>
<body ng-app="myApp">
    <p><a href="#/!">Main</a></p>
    <a href="#/red">Red</a>
    <a href="#/green">Green</a>
    <a href="#/blue">Blue</a>
    <div ng-view></div>
    var app = angular.module("myApp", ["ngRoute"]);
    app.config(function($routeProvider) {
      .when("/", {
        templateUrl : "main.html"
      .when("/red", {
        templateUrl : "red.html"
      .when("/green", {
        templateUrl : "green.html"
      .when("/blue", {
        templateUrl : "blue.html"
*Expected behavior* The Angular SPA works fine with ngRoute navigation in WkWebview, as did in UIWebView.


Screen Shot 2019-07-24 at 6.43.48 PM.png2019-07-24T15:44:03.000+000022684
Screenshot 2019-10-26 at 2.22.43 PM.png2019-10-26T08:25:30.000+000016480
Simulator Screen Shot - iPad Air 2 - 2019-08-19 at 15.45.08.png2019-08-19T09:47:38.000+000074972


  1. Muhammad Ahmed Fahad 2019-06-21

  2. Portal 2019-07-24

    any news? It starts getting critical because we can't migrate sdk as far as loading local templates causes cors errors.
  3. Muhammad Ahmed Fahad 2019-07-24

    @Portal , if you are using your own API's you can solve your issue by adding this headers to your API's that you access using a webview: 'Access-Control-Allow-Origin': '*'
  4. Portal 2019-07-24

    @Muhammad Ahmed Fahad Unfortunately the issue is not related to an API call, we can't load html files through AngularJS routing because webview doesn't trust anymore ajax calls to load resources with the file URI scheme.
  5. Sharif AbuDarda 2019-07-24

    Hello, I have tested the sample HTML code as a local HTML file in a classic app. I don't see any error during runtime. I have tested with SDK 8.0.2.GA in iOS simulator. The webview loads fine. !Screen Shot 2019-07-24 at 6.43.48 PM.png|thumbnail! . Try with the latest SDK 8.0.2.GA. Let us know. Thanks.
  6. Portal 2019-07-26

    We tried updating to SDK 8.0.2.GA but keep getting the same error. Tested on simulator Ipad Air 2 IOS 12.1.
       [Error] Cross origin requests are only supported for HTTP.
       (funzione anonima) (angular.min.js:93:225)
       p (angular.min.js:89:99)
       (funzione anonima) (angular.min.js:86:247)
       (funzione anonima) (angular.min.js:119:115)
       $digest (angular.min.js:130:239)
       $apply (angular.min.js:133:520)
       (funzione anonima) (angular.min.js:20)
       d (angular.min.js:19:489)
       Zd (angular.min.js:19:85)
       (funzione anonima) (angular.min.js:293:241)
       a (angular.min.js:174:401)
       c (angular.min.js:35:222)
       [Error] XMLHttpRequest cannot load file:///Users/sviluppo/Library/Developer/CoreSimulator/Devices/640896B1-CF62-4872-B0B8-A456BCC410EC/data/Containers/Bundle/Application/17D7E690-5EBA-4B58-BC33-194984FE1911/Test%20App.app/html/views/main.html due to access control checks.
       (funzione anonima) (angular.min.js:93:225)
       p (angular.min.js:89:99)
       (funzione anonima) (angular.min.js:86:247)
       (funzione anonima) (angular.min.js:119:115)
       $digest (angular.min.js:130:239)
       $apply (angular.min.js:133:520)
       (funzione anonima) (angular.min.js:20)
       d (angular.min.js:19:489)
       Zd (angular.min.js:19:85)
       (funzione anonima) (angular.min.js:293:241)
       a (angular.min.js:174:401)
       c (angular.min.js:35:222)
  7. Rakhi Mitro 2019-08-19

    Hello, Tested this with SDK 8.1.0.GA on Ipad Air 2 and got the following output: !Simulator Screen Shot - iPad Air 2 - 2019-08-19 at 15.45.08.png|thumbnail! Can you please test this on SDK 8.1.0.GA and let us know the result?
  8. Portal 2019-08-20

    Hello, we tried updating to sdk 8.1.0.GA but we keep getting this error during installation: [ERROR] : Error: spawn EACCES at _errnoException (util.js:992:11) at ChildProcess.spawn (internal/child_process.js:323:11) at exports.spawn (child_process.js:502:9) at iOSBuilder. (/Users/sara.quattrini/Library/Application Support/Titanium/mobilesdk/osx/8.1.0.GA/iphone/cli/commands/_build.js:6012:19) at Object.whilst (/Users/sara.quattrini/Library/Application Support/Titanium/mobilesdk/osx/8.1.0.GA/node_modules/async/dist/async.js:5227:5) at iOSBuilder. (/Users/sara.quattrini/Library/Application Support/Titanium/mobilesdk/osx/8.1.0.GA/iphone/cli/commands/_build.js:5999:9) at checkEntitlements (/Users/sara.quattrini/.appcelerator/install/7.0.11/package/node_modules/appc-cli-titanium/hook/titanium.js:630:15) at iOSBuilder.data.fn (/Users/sara.quattrini/.appcelerator/install/7.0.11/package/node_modules/appc-cli-titanium/hook/titanium.js:623:10) at /Users/sara.quattrini/.appcelerator/install/7.0.11/package/node_modules/titanium/lib/hook.js:256:13 at /Users/sara.quattrini/.appcelerator/install/7.0.11/package/node_modules/titanium/node_modules/async/dist/async.js:3853:9 Can you give us some hint to fix it? Thanks
  9. Sharif AbuDarda 2019-08-21

    Hello, Here are a couple of things to try and let us know if this works for you. * Make sure you have the latest Appc CLI from NPM : sudo npm install -g appcelerator * To check which version you are on, run : npm list -g --depth 0 appcelerator * run the setup command with debug and trace flags turned on : DEBUG=* appc setup -l trace Next, try a clean install of your Appc CLI: * Uninstall Appc CLI from NPM global path : sudo npm uninstall -g appcelerator * Remove Appc CLI installed locally : sudo rm -rf .appcelerator * Cache clean from NPM : sudo npm cache clean * Then, reinstall Appc CLI from NPM : sudo npm install -g appcelerator * Run setup : appc setup Thanks.
  10. Portal 2019-08-26

    We managed to install the app with the new SDK but it continues to fail routing showing us just a blank page. Could you share with us the working sample tested with SDK 8.1.0.GA? Could it be a problem linked to environment configuration?
  11. Portal 2019-09-05

    Could you share with us the working sample tested with SDK 8.1.0.GA? Could it be a problem linked to environment configuration?
  12. Portal 2019-09-16

    Hi again, any news?
  13. Rakhi Mitro 2019-09-16

    Hello , Can you please test this issue on 8.1.1.GA and let us know the results?
  14. Portal 2019-09-16

    Hi, we tested 8.1.1.GA and we are getting the same error described for 8.0.2.GA.
  15. Rakhi Mitro 2019-10-26

    Hello, Are you able to get that sorted out? Tested this issue on 8.2.1.GA and got the following as output: !Screenshot 2019-10-26 at 2.22.43 PM.png|thumbnail! Can you please test this on 8.2.1.GA? Please let us know if you need more help with this issue.
  16. Portal 2019-11-19

    Tested and got same error (iOS 13.0). Could you please give us a sample code showing how you are instantiating and loading the webview? Thanks
  17. Fazlul Haque 2019-12-30

    Hi [~portal@quix.it], If I just add the index.html on any project then Create a window containing a webview with url:'index.html' using latest SDK 8.3.0.GA, I cannot reproduce the issue on my end. My test code is:
        var win = Ti.UI.createWindow();
        var webview = Ti.UI.createWebView({
        	url : 'index.html'
    Can you please test it on latest SDK and let us know if you have the same issue? Thanks
  18. Portal 2020-01-13

    Same error. The error is triggered when trying to navigate to other pages from the index (red, green or blue html from the example), index.html is correctly displayed. We seriously need it working, we can't go on with workarounds anymore...
  19. Vijay Singh 2020-02-21

    See TIMOB-27159. Probably it will fix the issue. It has new property 'assetsDirectory' which can be used to whitelist the resources. Let me know if it fixes or share a complete test app. Thanks!
  20. Portal 2020-03-16

    Unfortunately we tried and it doesn't fix the issue because the problem is not linked to titanium impossibility to load the file from resources. The WKWebView enforces strict CORS settings so angularjs is unable to load urls with file scheme. The test described in the task is still valid... just try to navigate using angularjs routing inside the webview.

JSON Source