admin管理员组

文章数量:1122832

I’m building a Chrome extension using the WXT framework and trying to integrate Firebase Google authentication, but I keep running into CSP-related issues. Here’s the situation:

Error from Content Security Policy (CSP):

Refused to load the script '.js?onload=__iframefcb620453' because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' http://localhost:3000". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
Firebase auth error:
Uncaught (in promise) FirebaseError: Firebase: Error (auth/internal-error).

I can’t find where to catch this error, so debugging it has been difficult

My attempts:

I suspect the problem is related to the manifest.json configuration, particularly the content_security_policy field. Using the WXT framework, I tried defining the CSP like this:

import { defineConfig } from "wxt";

// See /api/config.html
export default defineConfig({
  srcDir: "src",
  extensionApi: "chrome",
  modules: ["@wxt-dev/module-svelte"],
  manifest: {
    content_security_policy: {
      extension_pages:
        "script-src 'self' 'wasm-unsafe-eval' http://localhost:3000 ; object-src 'self';",
    },
  },
});

However, when I include in the CSP, the extension fails to load and throws this error:

Failed to load extension from: /<my project directory>/.output/chrome-mv3. 'content_security_policy.extension_pages': Insecure CSP value "; in directive 'script-src'.

This is my first time building an extension and first using WXT too. So any help would be great

本文标签: