头盔CSP无法正常工作?

时间:2018-07-22 23:04:51

标签: node.js security express content-security-policy helmet.js

使用Express发行的Vue SPA。

这是我快递中的头盔代码

app.use(helmet.contentSecurityPolicy({
  directives: {
   defaultSrc: ["'self'"],
   styleSrc: ["'self'","'unsafe-inline'" ,'unpkg.com', 'cdn.jsdelivr.net', 
   'fonts.googleapis.com', 'use.fontawesome.com'],
   scriptSrc: ["'self'","'unsafe-inline'",'js.stripe.com'],
   frameSrc: ["'self'",'js.stripe.com'],
   fontSrc:["'self'",'fonts.googleapis.com','fonts.gstatic.com','use.fontawesome.com','cdn. joinhoney.com']
 }
}));

这样做不会在浏览器控制台中产生任何错误,但是我的页面加载为空白,是否缺少任何内容?

以下是我要在index.html中导入的内容

<script src="https://js.stripe.com/v3/"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.5.2/animate.min.css">
<link href="https://unpkg.com/vuetify/dist/vuetify.min.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Roboto:300,400,500,700%7CMaterial+Icons' rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">

1 个答案:

答案 0 :(得分:0)

通过在我的scriptSrc中添加“'unsafe-eval'”来解决我的问题