Skip to content

Commit

Permalink
disable draco, to not have to enable eval in CSP
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisweb committed Sep 30, 2024
1 parent 9533a72 commit 7d23360
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion components/neonRoad/Palm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ const PALM_GLTF_PATH = '/assets/3d_models/palm/palm.gltf'
// code for the gltf version
const PalmModel = forwardRef<Group, GroupProps>((props, ref) => {

const { nodes, materials } = useGLTF(PALM_GLTF_PATH) as GLTFResult
// second parameter is false to disable draco (wasm decompression tool)
// modern browsers support the CSP directive 'wasm-unsafe-eval'
// but older browsers require the 'unsafe-eval' directive
// when draco is disabled there is no need for wasm, so also no need for 'unsafe-eval'
const { nodes, materials } = useGLTF(PALM_GLTF_PATH, false) as GLTFResult

return (
<group name={'PalmModel'} {...props} ref={ref}>
Expand Down
7 changes: 5 additions & 2 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ const securityHeadersConfig = (phase) => {
// unfortunatly because of fontawesome this is not possible (yet)
// https://github.com/FortAwesome/Font-Awesome/issues/20001

// removed 'wasm-unsafe-eval' from script-src
// draco compression needed that directive, but it is now disabled (in Palm.tsx)

// when environment is preview enable unsafe-inline scripts for vercel preview feedback/comments feature
// and whitelist vercel's domains based on:
// https://vercel.com/docs/workflow-collaboration/comments/specialized-usage#using-a-content-security-policy
Expand All @@ -314,7 +317,7 @@ const securityHeadersConfig = (phase) => {
${defaultCSPDirectives}
font-src 'self' https://vercel.live/ https://assets.vercel.com https://fonts.gstatic.com;
style-src 'self' 'unsafe-inline' https://vercel.live/fonts;
script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval' https://vercel.live/;
script-src 'self' 'unsafe-inline' https://vercel.live/;
connect-src 'self' https://vercel.live/ https://vitals.vercel-insights.com https://*.pusher.com/ wss://*.pusher.com/ ${reportingDomainWildcard};
img-src 'self' data: https://vercel.com/ https://vercel.live/;
frame-src 'self' https://vercel.live/;
Expand All @@ -329,7 +332,7 @@ const securityHeadersConfig = (phase) => {
${defaultCSPDirectives}
font-src 'self';
style-src 'self' 'unsafe-inline';
script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval';
script-src 'self' 'unsafe-inline';
connect-src 'self' https://vitals.vercel-insights.com ${reportingDomainWildcard};
img-src 'self' data:;
frame-src 'none';
Expand Down

0 comments on commit 7d23360

Please sign in to comment.