Content Security Policy
Introduction
This is a page dedicated to Content Security Policy (CSP). CSP provides a standard method for website owners to declare approved origins of content that browsers should be allowed to load on that website—covered types are JavaScript, CSS, HTML frames, web workers, fonts, images, embeddable objects such as Java applets, ActiveX, audio and video files, and other HTML5 features.
This is meant to be enough information to revisit and understand what to do when using CSP.
CSP with Node JS
Here is an example in Node JS so we can see what we are talking about.
var csp_headers = {
"default-src": ["'self'", "http://example.com"],
"connect-src": ["'self'", "http://example.com"],
"img-src": ["'self'", "data:", "http://example.com"]
};
app.use("/", function(req, res, done) {
csp.header(csp_headers, res);
done();
});
// Static files from ./public
app.use("/", express.static("./public"));