Answer the question
In order to leave comments, you need to log in
How to properly connect a script from helmet to node?
Refused to load the script ' https://code.jivosite.com/widget/qBBQfaHsH1 ' because it violates the following Content Security Policy directive: "script-src-elem 'self' https://cdnjs.cloudflare.com/ajax /libs/materialize... 'unsafe-inline'".
After connecting the helmet, you have to make additional settings in the Content Security Policy directive. I do it like this (below is the working code):
app.use( helmet({
contentSecurityPolicy: {
directives: {
...helmet.contentSecurityPolicy.getDefaultDirectives(),
"img-src": ["'self'", "https:"],//это для загрузки картинки http, без этого не работает
"script-src-elem": ["'self'", "https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js", "'unsafe-inline'" ]
}, // это для подключения внешнего скрипта , без этого не работает
},
})
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question