You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#7371 introduces a bug in cordova apps loading local assets. The fetch API doesn't support the file: scheme whereas xhr does (JakeChampion/fetch#92 (comment)) so when style specification or images are stored locally, they won't load after 0.51.0 (works fine up to 0.50.0).
It looks like no browser allows access via file:// URLs anyway´ due to security constraints. E.g. Chrome reports:
Access to XMLHttpRequest at 'file://test/integration/tiles/14-8803-5375.mvt' from origin 'file://' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
This behaviour is disabled in the webview cordova uses (only for xhr, not for fetch, it's probably not possible for fetch). Unfortunately I think it's not trivial to test it out, you need to install cordova, make a sample project and run it on a device. I can help with the testing.
I am also using ionic 3 which use cordova for building ios and android application. In my application it is working fine. I seen my application running on local web server.
@kkaefer Thanks. Actually it didn't directly fixed my use case besause I used relative URLs to load the local assets so the regexp isn't enough in this case. It works when I convert my URLs to absolute but it's not quite straightforward, you might get new bug reports about this.
I have the same problem. I use mapbox in react project with cordova but my pins images aren't loaded. Downgrading to 0.50.0 works fine. I also use relative paths.
Activity
mourner commentedon Nov 21, 2018
Yeah, we should probably switch to XHR when requesting a URL with a file protocol. Would you like to do a PR with the fix? cc @kkaefer
kkaefer commentedon Nov 23, 2018
It looks like no browser allows access via
file://URLs anyway´ due to security constraints. E.g. Chrome reports:Access to XMLHttpRequest at 'file://test/integration/tiles/14-8803-5375.mvt' from origin 'file://' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.gpiffault commentedon Nov 23, 2018
This behaviour is disabled in the webview cordova uses (only for xhr, not for fetch, it's probably not possible for fetch). Unfortunately I think it's not trivial to test it out, you need to install cordova, make a sample project and run it on a device. I can help with the testing.
mourner commentedon Nov 23, 2018
@kkaefer it's possible in certain environments like Cordova. We had related PRs before, e.g. this one #6610
ansarikhurshid786 commentedon Dec 4, 2018
I am also using ionic 3 which use cordova for building ios and android application. In my application it is working fine. I seen my application running on local web server.
kkaefer commentedon Jan 30, 2019
@gpiffault This should be fixed in #7818.
gpiffault commentedon Jan 31, 2019
@kkaefer Thanks. Actually it didn't directly fixed my use case besause I used relative URLs to load the local assets so the regexp isn't enough in this case. It works when I convert my URLs to absolute but it's not quite straightforward, you might get new bug reports about this.
denis1994 commentedon Jun 13, 2019
I have the same problem. I use mapbox in react project with cordova but my pins images aren't loaded. Downgrading to 0.50.0 works fine. I also use relative paths.
Detect relative file: requests
denis1994 commentedon Jul 8, 2019
@gpiffault I will test your commit and report here. Perhaps they can take it to the actual version.