mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 15:57:50 +01:00
stricter content security policy
This commit is contained in:
@@ -3,6 +3,7 @@ const http = require('http');
|
||||
const https = require('https');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const crypto = require('crypto');
|
||||
|
||||
const ServerBootstrapper = {
|
||||
processCLIArgs: () => {
|
||||
@@ -64,6 +65,15 @@ const ServerBootstrapper = {
|
||||
next();
|
||||
}
|
||||
});
|
||||
app.use(function (req, res, next) {
|
||||
let nonce = crypto.randomBytes(16).toString('base64');
|
||||
res.setHeader(
|
||||
'Content-Security-Policy',
|
||||
"default-src 'self'; font-src 'self' https://fonts.gstatic.com/; img-src 'self' https://img.buymeacoffee.com;" +
|
||||
" script-src 'self' https://cdnjs.buymeacoffee.com; style-src 'self' https://cdnjs.buymeacoffee.com https://fonts.googleapis.com/ 'nonce-" + nonce + "'; frame-src 'self'"
|
||||
);
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
return main;
|
||||
|
||||
Reference in New Issue
Block a user