我正在浏览器扩展。 当我试图连接火力地堡的网络应用程序,在2个可能的方式没有工作。
- 使用"故宫安装火力地堡" 当我试图这个命令要安装火力地堡进入我的项目文件夹写了fireConn.js 文件随着配置我从火力地堡的项目创建在线。
import {initializeApp} from 'firebase/app';
import {getFirestore} from 'firebase/firestore';
错,我得到的是
Uncaught TypeError: Failed to resolve module specifier "firebase/app". Relative references must start with either "/", "./", or "../".
- 使用 https://www.gstatic.com/firebasejs/9.4.1/firebase-app.js url获得连接的火力地堡
import {initializeApp} from "https://www.gstatic.com/firebasejs/9.4.1/firebase-app.js";
import {getFirestore} from "https://www.gstatic.com/firebasejs/9.4.1/firebase-firestore.js";
因为我的项目是一款名,我有一个清单。json文件,该文件是在以下格式:
{
"name": "xxx",
"manifest_version": 3,
"version": "1.0",
"permissions": ["cookies","tabs"],
"host_permissions": ["<all_urls>"],
"action": {
"default_popup": "popup.html"
},
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'",
"sandbox": "sandbox allow-scripts; script-src 'self' 'https://apis.google.com/' 'https://www.gstatic.com/' 'https://*.firebaseio.com' 'https://www.googleapis.com' 'https://ajax.googleapis.com'; object-src 'self'"
}
}
错,我得到的是:(一些东西错了与content_security_policy)
Refused to load the script 'https://www.gstatic.com/firebasejs/9.4.1/firebase-firestore.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.