needpp
V2EX  ›  问与答

chrome 插件开发 content_security_policy 有偿求助

  •  
  •   needpp · Dec 21, 2022 · 790 views
    This topic created in 1246 days ago, the information mentioned may be changed or developed.

    想在谷歌插件中进行 pdf 下载,这个 pdf 是通过 pdfmake 生成的,但是遇到了 csp 问题;

    问题代码

    <iframe className='h-screen' src={pdfUrl}></iframe>
    
    

    bug 截图

    image

    尝试过的解决办法:

    1. 设置了 csp 白名单
      "content_security_policy": {
        "extension_pages": "child-src https: http: data: ;  script-src 'self' 'unsafe-inline'; object-src 'self' 'data:'; frame-src 'self' 'unsafe-inline' 'data:'"
      }
      
    

    但是似乎这些改动,没有体现到控制台;

    1. 排除其他原因: 把 iframe 中的 pdfUrl 固定写成 test.pdf ,能够正常展示

    2. 怀疑问题: 是否是 mainfestv3 版本导致?

    希望踩过坑的朋友分享下经验,把提供思路帮我解决问题也附上红包感谢;

    交个朋友,后续有问题会继续付费求助,谢谢

    needpp
        1
    needpp  
    OP
       Dec 21, 2022
    已解决,结贴
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1482 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 17:00 · PVG 01:00 · LAX 10:00 · JFK 13:00
    ♥ Do have faith in what you're doing.