거절 로드 스크립트'https://www.gstatic.com/firebasejs/9.4.1/firebase-app.js'을 위반하기 때문에 다음과 같은 콘텐츠 보안 정책

0

질문

나는 작업을 chrome 브라우저에서 확장. 을 연결하는 중포 기지와에서 웹 앱은 2 가지 방법이 없음이 작동하는 것입니다.

  1. "를 사용하여 본원에 설치 중포 기지" 가 이 명령을 설치 중포 기지로 프로젝트 폴더에 쓰 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 "../".
  1. 를 사용하는 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.
1

최고의 응답

0

첫째,수정의 수입으로 아래:

import { initializeApp } from "https://www.gstatic.com/firebasejs/9.4.1/firebase-app.js";
import { getFirestore, collection, getDocs } from "https://www.gstatic.com/firebasejs/9.4.1/firebase-firestore.js";

자세한 정보를 찾을 수 있습니다 그것에 대해서 문서. 을 사용하기 때문에 모듈의 번들러,필요 type="모듈의"추가됩니다. 올바른 형식으로 이어야 한다:

<script type="module" src="........”></script>

참고:src 는 방법에 따라 당신은 경로를 설정합니다.

참조할 수 있습니다 비디오를 시작 중포 기지를 위한 웹 중포 기지 기본. 또한, 연결할 수 없는 중포 기지,처리되지 않은 오류가에서 중포 기지 추가할 수 있습니다.

2021-11-22 09:28:05

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................