magento / pwa-studio

🛠Development tools to build, optimize and deploy Progressive Web Applications for Magento 2.
https://developer.adobe.com/commerce/pwa-studio/
Open Software License 3.0
1.06k stars 682 forks source link

[bug]: PWA content security policy restricting camera to scan the barcode. #4167

Open prajeswari opened 12 months ago

prajeswari commented 12 months ago

I need barcode functionality in my PWA instance. So I have taken quaggajs library and implemented the code. But I am getting below errors on console after giving permission to camera on browser.

61.22b88ce37246476835f9.js:240 Refused to create a worker from 'blob:[project url/6054352f-e2f0-49cb-9588-80fcbc7dca81']({project url}/6054352f-e2f0-49cb-9588-80fcbc7dca81%27) because it violates the following Content Security Policy directive: "child-src 'self'". Note that 'worker-src' was not explicitly set, so 'child-src' is used as a fallback.

Can any one help me on this with solution. To reproduce

1)Taken Magento 2.4.6 P1 instance 2)Add quagga library with yarn add quagga 3)Implement the view and code for quagga intialization. 4)Access the url and give camera permission and check the console.

Expected behavior

After giving camera permission no errors should be there on console and we need to scan the barcode.

image

Added code below which I implemented for barcode functionality. BarcodeScanner.js image AddBarcodeScannerPage.js for view. image

Please let us know what packages this bug is in regards to:

m2-assistant[bot] commented 12 months ago

Hi @prajeswari. Thank you for your report. To speed up processing of this issue, make sure that you provided sufficient information. Add a comment to assign the issue: @magento I am working on this


Join Magento Community Engineering Slack and ask your questions in #github channel.

glo80771 commented 11 months ago

As this is an issue with the third-party module Quagga, hence we are inviting community contribution to it.