Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
refactor(server): replace json parse stringify with `structuredClone(…
Browse files Browse the repository at this point in the history
…)` (#691)
  • Loading branch information
Fdawgs committed Apr 18, 2023
1 parent 6adb849 commit 64bcabc
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/server.js
@@ -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 @@ -171,15 +170,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 64bcabc

Please sign in to comment.