HJ29 / vue3-qr-reader

89 stars 25 forks source link

Unable to use offline #2

Closed beruic closed 3 years ago

beruic commented 3 years ago

I'm working on a Capacitor app project where want to use vue3-qr-reader (because it works great). However in order to do so, we need to load jsQR locally.

Unfortunately https://cdn.jsdelivr.net/npm/jsqr@1.3.1/dist/jsQR.min.js is hard-coded in src/worker/jsqr.js.

Can it somehow be made configurable?

Another problem we have is that we have to add https://cdn.jsdelivr.net/ to our Content-Security-Policy, which is not good.

HJ29 commented 3 years ago

Hi, thanks for reporting this issue. this package is basically a clone from https://github.com/gruhn/vue-qrcode-reader, but with vue 3 syntax. here is the issue from original package. there are some workaround suggested from the owner of package, if u need to do this urgently, u can give it a try. I didn't try it out before, so i am not sure if those workaround is working and compatible with this package.

btw, since v3.0.0 of the original package stop using worker and the js script, replaced by barcode-detector polyfill, here is the commit if u r interested. I am going to implement this too, but i don't have a deadline, maybe this weekend, maybe not.

beruic commented 3 years ago

For now I have patched this in our build system.

Just want to share this with you, as I think it could be helpful: For relative URLs you need to prepend them with location.origin. E.g. location.origin + "/scripts/jsqr/jsQR.js".

I guess then you can just look at whatever argument you inject into the worker, and append that to all urls not starting with http:// or https://.

HJ29 commented 3 years ago

v1.0.0 removed dependency on https://cdn.jsdelivr.net/npm/jsqr@1.3.1/dist/jsQR.min.js