How to get corova to load config.xml from subdirectory

Sorry if this has been answered multiple times, but I did search and didn’t find an answer.

I ran the following command “ionic build browser --prod --release” to build the app, then uploaded it to a subdirectory. Everything else seems to work fine, but cordova is trying to get the config.xml from the root public directory instead of the subdirectory the app is uploaded to.

The app is at https://domainname.com/storebr, and what I’m getting is the following error: cordova.js:846 [Browser][cordova.js][xhrStatusChangeHandler] Could not XHR config.xml, and the request is made to https://domainname.com/config.xml

We have more than one app, so just loading the config.xml from the root public directory is not an option.

What do I need to change in my setup?

Hm, can you post the actual URL (or PM it to me) so I can have a look? Interesting problem.

Sure, the url is https://qrsnack.com/storebr . It’s an Apha app. I’m just experimenting with actual deployment, and I’m not 100% sure cordova will be in the final version, but it still seems that loading the config.xml from the same directory the app is in should be automatic. If not, I might consider that a bug.

I assume it would work if I served the app from a subdomain, and had the app in the root of that subdomain, so I guess there are other options too.

I actually didn’t know that `cordova-browser’ loads the config.xml on runtime… so I am looking into that now. I can see the broken request you mentioned.

Found it:



This might be a bug in cordova-browser!
This /config.xml should probably be a relative link or at least somehow handle the path of the app - but not just go to the root and then look for config.xml. This breaks - as you found out.

Looking at the console I see that this is actually triggered by https://qrsnack.com/storebr/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js line 127. Maybe try to temporarily the Splashscreen plugin to see if the error goes away.

If it does, next step would be creating an issue for cordova-browser on issues.cordova.io

1 Like

Ok, thanks. I actually had found that line previously, but didn’t know if I should change it or not

Changing it in confighelper.js has no effect, but changing it in cordova.js (line 875 in my file) did load the config.xml file

try {
xhr.open(“get”, “/storebr/config.xml”, true);
xhr.send();
} catch(e) {
fail(’[Browser][cordova.js][readConfig] Could not XHR config.xml: ’ + JSON.stringify(e));
}

Ok. Please create an issue at issues.cordova.io and post the link to it here. It is important that this gets reported so it can be fixed (in a generalized way that works for all projects).

Ok, thanks for your help.

OH… FYI… it looks like every cordova plugin (or at least most) trys to load the config file. It just broke on the splashscreen because it was the first (and only) plugin called on page load. So, it would definitely be an issue for anyone trying to run a cordova app from a subdirectory.

1 Like

Created the issue, but got the message “Issue created, but currently not visible”, and I didn’t copy the link fast enough. I just registered, so I imagine my post needs to be approved.

Here it is:

https://issues.apache.org/jira/browse/CB-13272

1 Like