75341704 edited a comment on issue #883:
URL: https://github.com/apache/cordova-ios/issues/883#issuecomment-651446075


   Follow codes hereunder,  cdvIsFileScheme may be the key point
   
   
   
https://github.com/apache/cordova-ios/blob/e6e90e07d1b04bf5fcafc14578f1c4fb8bd86386/CordovaLib/Classes/Public/CDVViewController.m#L273
   
https://github.com/apache/cordova-ios/blob/e6e90e07d1b04bf5fcafc14578f1c4fb8bd86386/CordovaLib/Classes/Public/CDVViewController.m#L319
   
https://github.com/apache/cordova-ios/blob/e6e90e07d1b04bf5fcafc14578f1c4fb8bd86386/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m#L301
   
https://github.com/apache/cordova-ios/blob/e6e90e07d1b04bf5fcafc14578f1c4fb8bd86386/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m#L304
   
https://github.com/apache/cordova-ios/blob/e6e90e07d1b04bf5fcafc14578f1c4fb8bd86386/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m#L160
   
   That is to say, if the scheme is not 'file://‘ , the code hereunder won't 
work. 
   
https://github.com/apache/cordova-ios/blob/e6e90e07d1b04bf5fcafc14578f1c4fb8bd86386/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m#L306
   
   But the scheme setting is also related to CORS in wkwebview.
   Yesterday I changed the scheme from app to file. 
   The local file from hot-code-push folder was working, but there is a 'null' 
origin error in safari debugger when the axios is used in my html project.
   
   As per https://github.com/oracle/cordova-plugin-wkwebview-file-xhr#readme, 
   =qte=
   This plugin makes it possible to reap the performance benefits of using the 
WKWebView in your Cordova app by resolving the following issues:
   
   The default behavior of WKWebView is to raise a cross origin exception when 
loading files from the main bundle using the file protocol - "file://". This 
plugin works around this shortcoming by loading files via native code if the 
web view's current location has "file" protocol and the target URL passed to 
the open method of the XMLHttpRequest is relative. As a security measure, the 
plugin verifies that the standardized path of the target URL is within the 
"www" folder of the application's main bundle or in the /Library path of the 
application data directory.
   
   Since the application's starting page is loaded from the device's file 
system, all XHR requests to remote endpoints are considered cross origin. For 
such requests, WKWebView specifies "null" as the value of the Origin header, 
which will be rejected by endpoints that are configured to disallow requests 
from the null origin. This plugin works around that issue by handling all 
remote requests at the native layer where the origin header will be excluded.
   =unqte=
   
   It may be the trade off between local file and CORS in the wkwebview?
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to