FranGhe opened a new issue, #1299:
URL: https://github.com/apache/cordova-ios/issues/1299

   When building app everything is ok... I have many ajax call to remote file 
(php) and everything it's ok because i can manage 
header("Access-Control-Allow-Origin: ...."); But the issue arises when I have 
to read/download images files.
   
   On config.xml I set
   ```
   <preference name="hostname" value="localhost" />
   <preference name="scheme" value="https" /> 
   ```
   And reading some post I also installed
   `@ahovakimyan/cordova-plugin-wkwebviewxhrfix`
   
   This is my code:
   ```
     var req = new XMLHttpRequest();
     req.open("GET", "https://www.mySite.xx/img/logo.jpg";, true);
     req.responseType = "blob";
     req.onload = function (event) {
         var blob = req.response;
         var storageLocation = cordova.file.dataDirectory;
   
         if(storageLocation){
             window.resolveLocalFileSystemURL(
                 storageLocation, 
                 function (directoryEntry) {
                     directoryEntry.getFile(
                         pathDest,
                         { create: true }, 
                         function (fileEntry) {
                             fileEntry.createWriter(
                                 function (fileWriter) {
                                     fileWriter.write(blob);
                                     fileWriter.onwriteend = function (e) { 
                                         //console.log('Write of file 
completed.'); 
                                         var split=pathDest.split("-");
                                         var cont=split[0];
                                         var thisContent=allAppData[cont];
                                         if(thisContent["temporaryImages"]){
                                             
thisContent.temporaryImages[key]=storageLocation+pathDest;
                                         }
                                         else{
                                             thisContent.temporaryImages={};
                                             
thisContent.temporaryImages[key]=storageLocation+pathDest;
                                         }
                                     };
                                     fileWriter.onerror = function (e) { 
console.log("downloadTemporaryFile -> Err01"); };
                                 },
                                 function (err) {
                                     console.log("downloadTemporaryFile -> 
Err02");
                                     console.error(err);
                                 }
                             );
                         },
                         function (err) {
                             console.log("downloadTemporaryFile -> Err03");
                             console.error(err);
                         }
                     );
                 },
                 function (err) {
                     console.log("downloadTemporaryFile -> Err04");
                     console.error(err);
                 }
             );
         }
     };
   req.send();
   ```
   
   On my console I have these errors:
   [Error] Origin app://localhost is not allowed by 
Access-Control-Allow-Origin. Status code: 200
   [Error] XMLHttpRequest cannot load https://www.mySite.xx/img/logo.jpg due to 
access control checks.
   [Error] Failed to load resource: Origin app://localhost is not allowed by 
Access-Control-Allow-Origin. Status code: 200
   
   I use the same code for Android an there aren't issue... How can I solve it?
   
   Thanks in advance
   
   
   
   


-- 
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.

To unsubscribe, e-mail: [email protected]

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