Skip to content

Commit

Permalink
Merge pull request #43 from PHS-TSA/checkboxes
Browse files Browse the repository at this point in the history
Fix CSP
  • Loading branch information
lishaduck authored May 9, 2024
2 parents c3af851 + 26b812e commit 457b8e3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/utils/csp.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
import { SELF, UNSAFE_INLINE, useCSP } from "$fresh/runtime.ts";
import {
NONE,
SELF,
STRICT_DYNAMIC,
UNSAFE_INLINE,
useCSP,
} from "$fresh/runtime.ts";

export function useCsp(): void {
useCSP((csp) => {
csp.directives.scriptSrc ??= [];
csp.directives.scriptSrcElem ??= [];
csp.directives.styleSrc ??= [];
csp.directives.styleSrcElem ??= [];
csp.directives.imgSrc ??= [];
csp.directives.connectSrc ??= [];
csp.directives.manifestSrc ??= [];
csp.directives.baseUri ??= [];

csp.directives.scriptSrc.push(STRICT_DYNAMIC, UNSAFE_INLINE);
csp.directives.scriptSrcElem.push(SELF, UNSAFE_INLINE);
csp.directives.styleSrc.push(SELF);
csp.directives.styleSrcElem.push(SELF, UNSAFE_INLINE);
csp.directives.imgSrc.push(SELF);
csp.directives.styleSrcElem.push(SELF, STRICT_DYNAMIC);
csp.directives.imgSrc.push(SELF, "data:");
csp.directives.connectSrc.push(SELF);
csp.directives.manifestSrc.push(SELF);
csp.directives.baseUri.push(NONE);
});
}

0 comments on commit 457b8e3

Please sign in to comment.