Origin app://localhost is not allowed by Access-Control-Allow-Origin

What platform are you building for?

iOS

What framework are you building with?

Cordova

What is your build ID?

87d32098-1bc1-4383-89bf-c050860a57d9

What is your error message?

Origin app://localhost is not allowed by Access-Control-Allow-Origin

Please describe the issue:

I’ve recently tried adding a panel of HTML formatted messages to my app. When I run my app in a browser, the messages are downloaded and placed in the divs perfectly, but in iOS, the messages don’t appear and the Safari developer console shows CORS errors. The mystery is that these messages are to replace messages in .png form downloaded from the same source and there is no problem downloading the .png files. Just to be sure that this isn’t a recent iOS upgrade problem, I’ve loaded onto the same phone one of my other apps which still has the .png functionality and this works perfectly

Further info:

Here is the CORS section of my config.xml file:

<access origin="*" />
<access origin="content:///*"/>
<allow-intent href="*" />
<allow-navigation href="*" />
<allow-navigation href="file:*" />

I've tried adding <access origin="app:///localhost" /> to my config.xml file, but this is rejected

Can you share the old URLs that worked, along with the new ones that are not working?

I’m away from the office until tomorrow afternoon. I’ll share those URLs then, once I’ve checked them out. BTW, I thought I’d changed my email address on your site but I seem to still be getting emails to my old one, which will stop working on Monday week. My old email address is Brian.Preece@btconnect.com and my new one is Brian.Preece1@outlook.com

Here is a screenshot from the developer window on MacOS Safari showing the cross-origin error messages for files with a .txt extension:

Here is a dump of the database from which the URLs are being loaded. The files with a .png extension are loaded fine without any cross-origin errors:

Images are not generally subject to CORS, whereas text files are. What method are you using to request the images? You may need to use a plugin so that you aren’t subject to browser based CORS restrictions.

Hi James

Thanks, I hadn’t realised that. I’m using the .load jquery method:

$(“#carousel-li-2”).load(thisMessageHTML);

Can you suggest a suitable plugin?

Much appreciated

NB My btconnect email address has now ceased. Your support people told me yesterday there had been a delay in updating the email address on my account to my new email address (brian.preece1@outlook.com) but hopefully it should be actioned today. In the meantime, I’ll check the forum page periodically in case I don’t get the email notification of a reply

Brian

Your forum account is separate from your VoltBuilder account, and you will have to update your email independently here.

You might try cordova-plugin-advanced-http - this will allow you to bypass CORS - however your best bet would be to configure the server to allow requests from your endpoint.

On the email thing, I’ll update that next week when I’m back. Regarding the CORS issue, I’ve sidestepped it by downloading the text in the files as data instead of as a file. Thanks for your help - can close the question now