Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Loading Chrome Extension - Insecure CSP value "" in directive 'script-src'

When Migrating MV2 to MV3, Chrome is throwing this error:

Example Error

Insecure CSP value "" in directive 'script-src'

Here's my content security policy:

"content_security_policy": {
    "extension_pages": "script-src 'self' 'https://www.fonts.googleapis.com' 'unsafe-eval'; object-src 'self'"
}

How can I fix this?

like image 868
jagdeep sharma Avatar asked May 20 '26 22:05

jagdeep sharma


1 Answers

According to the section on Remotely hosted code restrictions in the v2 to v3 migration guide:

Remotely hosted code refers to any code that is not included in an extension's package as a loadable resource. For example, the following are considered remotely hosted code:

  • JavaScript files pulled from the developer's server.
  • Any library hosted on a CDN.
  • a code string passed into eval() at runtime

In Manifest V3, all of your extension's logic must be included in the extension. You can no longer load and execute a remotely hosted file.

You'll have to download a local version of the script and reference that

Manifest V2 Page

<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">

Manifest V3 Page

<script src="./react-dom.production.min.js"></script>
<link href="./bootstrap.min.css" rel="stylesheet">
like image 50
KyleMit Avatar answered May 22 '26 11:05

KyleMit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!