Angular: ERROR rejection in promise - Safari only (iOS) - possible CORS issue?

81 Views Asked by At

I'm developing a mobile web app with Angular and ionic which parses a RSS in form of a XML with the 'rss-parser' library. Everything works fine on PC (Chrome, Edge) and on Android. But if I try to open it in Safari on my iPhone, I get the following error:

ERROR {"rejection": {}, "promise": {"__zone_symbol__state": 0, "__zone_symbol__value": "(Circular TypeError)"}, "zone": {"_parent": {"_parent": null, "_name": "<root>", "_properties": {}, "_zoneDelegate": {"_taskCounts": {"microTask": 0, "macroTask": 0, "eventTask": 0}, "zone": "(Circular Y)", "_parentDelegate": null, "_forkZS": null, "_forkDlgt": null, "_forkCurrZone": null, "_interceptZS": null, "_interceptDlgt": null, "_interceptCurrZone": null, "_invokeZS": null, "_invokeDlgt": null, "_invokeCurrZone": null, "_handleErrorZS": null, "_handleErrorDlgt": null, "_handleErrorCurrZone": null, "_scheduleTaskZS": null, "_scheduleTaskDlgt": null, "_scheduleTaskCurrZone": null, "_invokeTaskZS": null, "_invokeTaskDlgt": null, "_invokeTaskCurrZone": null, "_cancelTaskZS": null, "_cancelTaskDlgt": null, "_cancelTaskCurrZone": null, "_hasTaskZS": null, "_hasTaskDlgt": null, "_hasTaskDlgtOwner": null, "_hasTaskCurrZone": null}}, "_name": "angular", "_properties": {"isAngularZone": true}, "_zoneDelegate": {"_taskCounts": {"microTask": 0, "macroTask": 0, "eventTask": 72}, "zone": "(Circular Y)", "_parentDelegate": "(Circular D)", "_forkZS": null, "_forkDlgt": null, "_forkCurrZone": null, "_interceptZS": null, "_interceptDlgt": null, "_interceptCurrZone": null, "_invokeZS": {"name": "angular", "properties": "(Circular Object)", "onInvokeTask": onInvokeTask(), "onInvoke": onInvoke(), "onHasTask": onHasTask(), "onHandleError": onHandleError()}, "_invokeDlgt": "(Circular D)", "_invokeCurrZone": "(Circular Y)", "_handleErrorZS": "(Circular Object)", "_handleErrorDlgt": "(Circular D)", "_handleErrorCurrZone": "(Circular Y)", "_scheduleTaskZS": {"name": "", "onHasTask": onHasTask(), "onScheduleTask": onScheduleTask(), "onInvokeTask": onInvokeTask(), "onCancelTask": onCancelTask()}, "_scheduleTaskDlgt": "(Circular D)", "_scheduleTaskCurrZone": "(Circular Y)", "_invokeTaskZS": "(Circular Object)", "_invokeTaskDlgt": "(Circular D)", "_invokeTaskCurrZone": "(Circular Y)", "_cancelTaskZS": "(Circular Object)", "_cancelTaskDlgt": "(Circular D)", "_cancelTaskCurrZone": "(Circular Y)", "_hasTaskZS": "(Circular Object)", "_hasTaskDlgt": "(Circular D)", "_hasTaskDlgtOwner": "(Circular D)", "_hasTaskCurrZone": "(Circular Y)"}}, "task": {"_zone": "(Circular Y)", "runCount": 0, "_zoneDelegates": null, "_state": "notScheduled", "type": "microTask", "source": "Promise.then", "data": {"__zone_symbol__state": true, "__zone_symbol__value": undefined}, "scheduleFn": undefined, "cancelFn": undefined, "callback": function(), "invoke": function()}}

This is everything I can see on my iPhone using vConsole (I don't have a Mac to debug it properly). I've tested deploying my app on an Oracle cloud VM (linux) and Azure. Both don't work...

What I'm doing is simply call the method parseURL from rss-parser passing the XML url:

apiUrl = 'https://rss.app/feeds/OMITTING.xml/';

async parseUrl() {
    let feed: any;
    await this.parser.parseURL(this.apiUrl)
    .then(result => {
      console.log('Result ok: ');
      console.log(result);
      feed = result;
    })
    .catch (error => {
      throw(error);
    });
    console.log('Out: ');
    console.log(feed);
    return feed!.items;
  }

What makes me confused is that it works if I append "https://cors-anywhere.herokuapp.com/" to the URL, which makes me think it has something to do with CORS. But why does it happen only in Safari?? As a last try, I've created my own cors-anywhere instance on a linux server and ran it with "node server.js". Also in this case, my app works everywhere except on Safari. Do you know what I'm missing here? This is driving me crazy since one day.

0

There are 0 best solutions below