Skip to content

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

Closed
@prajeswari

Description

@prajeswari

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:

  • venia-concept
  • venia-ui
  • pwa-buildpack
  • peregrine
  • pwa-devdocs
  • upward-js
  • upward-spec
  • create-pwa

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions