带有NodeJS:EvalError的APIDoc在提供文档页面时出错



我正在使用APIDoc生成NodeJS应用程序的API文档。我在提供生成的index.html页面时遇到问题:Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".此处的问题消息屏幕截图如何解决此错误?

我已经尝试关闭安全并在该html页面的<meta>中发送script-src 'self'。我只需要这一页的工作表。

您可能有三种选择:

  1. 将"unsafe-eval"添加到脚本src中,这将使其工作,但您不会得到尽可能严格的CSP(但比根本没有CSP要好得多(
  2. 如果您的代码包含eval、setInterval、setTimeout或new Function,请尝试按照此处的建议进行重写:https://developers.google.com/web/fundamentals/security/csp#eval_too
  3. 如果问题出现在第三方代码中,请查看是否可以以某种方式进行替换

在元标记中添加另一个CSP没有帮助。所有政策都需要通过,您只能通过添加另一项政策来使其更加严格。

最新更新