【问题标题】:Ext JS - on sencha production build, sencha cmd is removing extra attribute in index.html fileExt JS - 在 sencha 生产版本中,sencha cmd 正在删除 index.html 文件中的额外属性
【发布时间】:2021-02-02 02:34:24
【问题描述】:

对于内容安全策略,我在 microloader 脚本标签中添加了nonce,以绕过在生产构建后重写 index.html 时生成的内联脚本,如下所示

script id="microloader" nonce="random" data-app="random-app" type="text/javascript" src="bootstrap.js"

但我观察到nonce="random" 在 sencha 构建(生产)之后得到剥离。
正因为如此,csp 是通过嵌入在 script 标签之间的内联 JS 的错误。

如何停止 sencha 删除添加的nonce

【问题讨论】:

    标签: extjs content-security-policy sencha-cmd nonce


    【解决方案1】:

    您要更新哪个文件?build\production\SenchaApp.. 不要更新这个,因为它总是被 sencha cmd 重写。最好更新根级 index.html 然后重新构建

    【讨论】:

    • 我已经更新了根级原始文件中的随机数。但是在 'sencha app build production' 之后,在这个 'build\production\SenchaApp' 路径中,由于 sencha 正在重写文件,它会删除上述位置的 nonce。 app.json 中是否有任何配置可以将 nonce 保留在那个地方?
    【解决方案2】:

    我建议在 build.xml ant 脚本中使用 --after-build 目标。从那里您可以手动编辑/更新构建的 index.html 以将 nonce 属性自动插入到脚本标记中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多