Skip to content

Commit

Permalink
refactor(server): replace json parse stringify with `structuredClone(…
Browse files Browse the repository at this point in the history
…)` (#1419)
  • Loading branch information
Fdawgs authored Apr 18, 2023
1 parent 031848b commit 06c1814
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const autoLoad = require("@fastify/autoload");
const fp = require("fastify-plugin");
const path = require("upath");
const secJSON = require("secure-json-parse");

// Import plugins
const accepts = require("@fastify/accepts");
Expand Down Expand Up @@ -136,15 +135,12 @@ async function plugin(server, config) {
* security of other routes
*/
.register(async (publicContext) => {
const relaxedHelmetConfig = secJSON.parse(
JSON.stringify(config.helmet)
);
const relaxedHelmetConfig = structuredClone(config.helmet);
Object.assign(
relaxedHelmetConfig.contentSecurityPolicy.directives,
{
"script-src": ["'self'", "'unsafe-inline'"],
"style-src": ["'self'", "'unsafe-inline'"],
"child-src": ["'self'"],
}
);

Expand Down

0 comments on commit 06c1814

Please sign in to comment.