futurepress / epub.js

Enhanced eBooks in the browser.
http://futurepress.org
Other
6.39k stars 1.09k forks source link

Unable to read renderless.html file when i change the url to my book #1369

Open awahab3109 opened 7 months ago

awahab3109 commented 7 months ago

I was using renderless.html as an example to get all the data in sections so that I can apply turn.js library on it. The problem i am facing regarding opening of the book is that when i use the url as specified in example, (https://s3.amazonaws.com/epubjs/books/moby-dick/OPS/package.opf), i get all the section data ,but when i changed it into my own url, it throws an error on book.spine.get(item) function. It shows CORS error, although i already have set the CORS Origin on my digital ocean , I also tried to set {contained:true} in my book constructor, but no result. Screenshot from 2024-01-14 19-59-18 If it's really a cors error why am I unable to open it using file input too. Keep in mind, I am able a file i downloaded from google, but unable to open the one I built myself

zhanglun commented 5 months ago

As shown in the error message in the screenshot, you cant access "file://xxx" with XMLHTTPRequest. By default, XMLHttpRequest (XHR) is not allowed to access the file:// protocol for security reasons. This is due to browser policies and security restrictions.

maybe you can serve your demo with local server and access the files via the HTTP or HTTPS protocol.

awahab3109 commented 3 months ago

As shown in the error message in the screenshot, you cant access "file://xxx" with XMLHTTPRequest. By default, XMLHttpRequest (XHR) is not allowed to access the file:// protocol for security reasons. This is due to browser policies and security restrictions.

maybe you can serve your demo with local server and access the files via the HTTP or HTTPS protocol.

thanks for the reply, but unfortunately your solution didn't work

johnfactotum commented 5 days ago

See https://github.com/futurepress/epub.js/issues/1397#issuecomment-2323135341