As far as I understand, there are two ways to specify the Content Security Policy:
- On a server side via headers:
res.setHeader("content security-policy", "default-src: 'none';")
- In an HTML-page via
meta
-tag:
<meta content = "default-src 'none';" http-equiv = "Content-Security-Policy" />
My questions:
What is the difference between these two techniques?
Is it enough to use just one of them?
Which one should I use? Backend, frontend, or both?
P.S. Thanks to How does Content Security Policy (CSP) work?, I know what is the CSP and how does it work. What I want to know, however, is where exactly it is better to set the CSP.