-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Browser extension Manifest version 3 is experiencing issues with Tesseract.js #961
Comments
You can include all files locally rather than using a CDN. This is documented here. Additionally, multiple other users have made browser extensions using Tesseract.js (including one prominently featured in the readme), so you can check what they did to handle this. |
Thank you for replying, Balearica. Tesseract.js is performing well with Manifest version 2 for scripts that are requested from both local and CDN. While migrating the project from Manifest version 2 to Manifest version 3, the "Content Security Policy" does not allow for internal and external script calling. Even though the script is also included in the project. Below is the generated error after configured Tesseract.js locally Refused to load the script 'chrome-extension://cfdfhbbeijbeiekpobjehilaniekfaoo/libs/tesseract/worker.min.js' because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules' http://localhost:* http://127.0.0.1:*". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback. Uncaught Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'chrome-extension://cfdfhbbeijbeiekpobjehilaniekfaoo/libs/tesseract/worker.min.js' failed to load. ab3cd1d9-032a-4451-8885-83c0c1a70c6d:1 Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'chrome-extension://cfdfhbbeijbeiekpobjehilaniekfaoo/libs/tesseract/worker.min.js' failed to load. |
below is the updated code, which solves my issue.. Thanks const worker = await Tesseract.createWorker("eng", 1, {
|
@dhineshkoilpitchai @Balearica Can you help me out? This is my code below
from where did you copy the corePath and worker file from?
|
Tesseract.js version (5.1.1)
Describe the bug
In Manifest V3, all of the extension's logic must be part of the extension package. while configuring tesseract.js in my project which is expecting remotely hosted files from cdn (https://cdn.jsdelivr.net/npm/[email protected]/dist/worker.min.js)
The call to cdn javascript files is being blocked by Manifest V3
Below is the generated error
aaa463d1-3808-4913-b68b-301dd763c085:1 Refused to load the script 'https://cdn.jsdelivr.net/npm/[email protected]/dist/worker.min.js' because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules' http://localhost:* http://127.0.0.1:*". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
The text was updated successfully, but these errors were encountered: