Skip to content

Commit 37e0ecb

Browse files
committed
fix app/hubmessenger's csp
1 parent 735cd53 commit 37e0ecb

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

app/buildHeaders.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ const contents = `/*
66
Cross-Origin-Opener-Policy: same-origin
77
Cross-Origin-Resource-Policy: cross-origin
88
Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'; frame-ancestors 'none';
9-
${hstsName}: ${hstsValue}`
9+
${hstsName}: ${hstsValue}
10+
11+
/hubmessenger
12+
! Content-Security-Policy
13+
Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'; frame-ancestors ${process.env.VITE_HUB_ORIGIN};
14+
`
1015

1116
fs.writeFile('./dist/_headers', contents, (err) => {
1217
if (err != null) {

app/deploy.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
set -euo pipefail # https://stackoverflow.com/a/2871034
55
# set -x
66

7-
npx tsx --tsconfig ./tsconfig.deploy.json buildHeaders.ts
87
[[ -f "env.sh" ]] && source env.sh
8+
set -a
9+
[[ -f ".env.production" ]] && source .env.production
10+
set +a
11+
npx tsx --tsconfig ./tsconfig.deploy.json buildHeaders.ts
912
npx wrangler pages deploy ./dist --project-name app --branch main

hub/src/entry-server.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default createHandler(
7474
sandbox='allow-scripts allow-same-origin' // Changing this has security ramifications! https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox
7575
// "When the embedded document has the same origin as the embedding page, it is strongly discouraged to use both allow-scripts and allow-same-origin"
7676
// Since this iframe hosts `app.pentive.com` and this page is hosted on `pentive.com`, resulting in different origins, we should be safe. https://web.dev/sandboxed-iframes/ https://stackoverflow.com/q/35208161
77-
src={import.meta.env.VITE_APP_ORIGIN + '/hubmessenger.html'}
77+
src={import.meta.env.VITE_APP_ORIGIN + '/hubmessenger'}
7878
/>
7979
<div id='app'>{children}</div>
8080
{scripts}

0 commit comments

Comments
 (0)