titanium-sdk icon indicating copy to clipboard operation
titanium-sdk copied to clipboard

iOS: Cors issue in WKWebView (sdk 8.0.1)

Open quix-portal opened this issue 6 years ago • 0 comments

Describe the bug 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:

<html>
<head>
    <meta charset="utf-8">
    <title>test</title>
    <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>
</head>
<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>
    
    <script>
    var app = angular.module("myApp", ["ngRoute"]);
    app.config(function($routeProvider) {
      $routeProvider
      .when("/", {
        templateUrl : "main.html"
      })
      .when("/red", {
        templateUrl : "red.html"
      })
      .when("/green", {
        templateUrl : "green.html"
      })
      .when("/blue", {
        templateUrl : "blue.html"
      });
    });
    </script>
    </body>
</html>

Expected behavior The Angular SPA works fine with ngRoute navigation in WkWebview, as did in UIWebView.

Environment Titanium SDK version: 8.0.1

quix-portal avatar Jun 17 '19 11:06 quix-portal