Epub.js - Phonegap not working because of blob URI

≡放荡痞女 提交于 2019-12-05 21:21:32

I got the solution. The answer to all "Cordova doesn't accept URI" is always "Whitelist"

With the whitelist plugin I had in my config file:

<access origin="*" />

However, debugging i saw that the blob:/file://...uri was getting blocked in shouldAllowNavigation. Then I tried with:

<access origin="*" />
<allow-navigation origin="*" />

But! it still didn't work. Debugging a bit more, I saw that the WhitelistPlugin if you add a *it doesn't allow everything, but only http://, https://and data:. Finally, adding:

<access origin="*" />
<allow-navigation href="*" />
<allow-navigation href="blob:*" />

Fixed the issue for me.

Also, just in case it's helpful for someone, while I was testing, I tried downloading the .epub file from a server and extracting it in the filesystem (/data/data/package/...) and accessing it from there. For some reason, accessing local files with XHR Requests returns status: 0, like it failed, but the response is there. I had to edit epub.js file EPUBJS.core.requestmethod to accept responses if this.response is set (instead of expecting this.statusto be 200).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!