sql.js-httpvfs: Requirement of `content-length` breaks on Cloudflare Pages
Hello, first of all thanks for this super interesting project! It really blew my mind when I read the blog post 😃
I’m still just playing around with it and I’ve been able to get an example based on Svelte Kit working on Github Pages, but on Cloudflare Pages (which I really prefer) the library breaks because the HEAD request to the sqlite file doesn’t return a content-length header, triggering this error: https://github.com/phiresky/sql.js-httpvfs/blob/852374bc0fcf84fd7844eadbd1aa074baeee21c9/src/lazyFile.ts#L185
The lack of the header appears to be intentional according to Cloudflare: https://community.cloudflare.com/t/no-content-length-header-when-response-is-compressed/134475
Do you think it would be possible for the library to work without the header, or is it completely impossible/impractical?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (8 by maintainers)
I found an interesting workaround for this when searching for a solution to this problem on Netlify, in their forums.
I simply renamed the file to
database.sqlite3.png. Since the extension is arbitrary, you may be able to find a file extension that is treated differently by Cloudflare Pages. Certainly, audio and video would work, if it’s looking at extensions vs. mime types.Hi @ric2b,
Sorry for the off-topic comment, but I’ve also been trying to get the library to work with sveltekit, but I’ve been getting errors so far, I’ve managed to get it to work with svelte using the webpack template, but I want to use it with sveltekit for more flexibility.
I would appreciate your help.
Edit: I’ve found a repository on your account that demonstrates this concept, seems like the workaround was to copy
sql-wasm.wasmandsqlite.worker.jsin a file outsidenode_modulesand access them from there.Thanks,