Firestore + Chrome扩展程序内容策略规则

问题描述 投票:0回答:1

我尝试使用此:“ content_security_policy”:“ script-src'self''sha256-GgRxr ...'https://cdn.firebase.comhttps://www.gstatic.com/https://*firebaseio.com https://www.googleapis.com; object-src'self '; connect-src'self'wss://*firebaseio.com;“,

但是它不起作用,我已经阅读了很多教程,但是所有教程都只涉及将Chrome Extension与Firebase连接。我没有看到有关将Chrome Extension与Firestore连接的任何信息。

当前,这是一个ReactJS Web项目,因此,如果我使用“ yarn start”加载普通网站,则一切运行正常。但是,当我将其与扩展名一起使用时,数据文档不会更新为Firestore。

对不起,我的英语。

google-chrome-extension google-cloud-firestore content-security-policy
1个回答
0
投票

您可以通过使用manifest.json上的“ externally_connectable”属性来消除content_security_policy错误,并将其与Firestore使用的googleapis.com域进行匹配:

  "externally_connectable": {
    "matches": ["*://*.googleapis.com/*"]
  },

仅当您对Firestore的请求是从扩展本身而不是从content.js脚本发出的时,这才有效,不幸的是,如果尝试从内容脚本触发请求,则会收到CORB错误-您可以在此链接上找到更多信息:https://www.chromium.org/Home/chromium-security/extension-content-script-fetches

© www.soinside.com 2019 - 2024. All rights reserved.