问题
Using Vue SPA distributed by Express.
this is my helmet code in express
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']
}
}));
Doing this produces no errors in the browser console but my page loads blank , am I missing something ?
Here is the stuff i'm trying to import in my 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:
Solved my issue by adding "'unsafe-eval'" to my scriptSrc
来源:https://stackoverflow.com/questions/51469937/helmet-csp-not-working-correctly