Skip to content

Refused to create a worker from blob: CSP error #372

Closed

Description

@robgoodberry

Due to the content security policy in our app containing worker-src: self I get an error when react-scan loads due to the app refusing to create the worker like:

react-scan.ts:10 Refused to create a worker from 'blob:https://<redacted>' because it violates the following Content Security Policy directive: "worker-src 'self'".

I'd prefer not to add blob: here. However, react-scan still seems to function as I would expect. Is there some fallback for the worker that makes it unnecessary, or is it required for some functionality only? Thanks in advance

Activity

  1. RobPruzan commented on May 2, 2025

    @RobPruzan
    Contributor

    Yeah we have a fallback for usage without workers. We can add an option for scan({...}) to control this explicitly

  2. aidenybai commented on May 2, 2026

    @aidenybai
    Owner

    Fixed in v0.5.5 via #437.

    Two changes:

    • Added useOffscreenCanvasWorker option. Set it to false and React Scan won't attempt the blob worker at all, so your CSP doesn't see the violation. The fallback to main-thread rendering already worked, but this lets you skip the failed attempt entirely.
    • Stopped console.warn-ing on worker-creation failure unless _debug: 'verbose' is set, so even with the default config you no longer get the noisy CSP error per page load.
    scan({
      useOffscreenCanvasWorker: false,
    })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions