Commit ccd171f
committed
fix(csp): use 'unsafe-inline' for style-src (match cloud-portal) to stop Safari refusing stylesheets
Strict nonce-based style-src made Safari refuse the <style>/<link> stylesheets
that CSS-in-JS libraries (sonner toasts, Radix UI) inject without a nonce
("Refused to apply a stylesheet because its hash, its nonce, or 'unsafe-inline'
does not appear in the style-src directive"), breaking styling. Inline style
attributes and injected stylesheets cannot carry a nonce, and per CSP3 a nonce
in the directive disables 'unsafe-inline' — so the nonce is dropped from
style-src and 'unsafe-inline' is used in dev and prod.
Mirrors datum cloud-portal (app/server/entry.ts: strict script-src nonce +
"Allow inline styles for third-party widgets"). script-src stays strict
(NONCE + 'strict-dynamic'), which is the real XSS boundary; style-based
injection is low-risk.
Supersedes the earlier revert (3e4c6a3): that kept the strict policy assuming
the violations were cosmetic, but Safari refusing stylesheets is a real visual
break. Tests assert the new style-src policy and the script-src nonce invariant.1 parent 728d246 commit ccd171f
3 files changed
Lines changed: 21 additions & 8 deletions
File tree
- app/server
- edge
- __tests__
- middleware/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
59 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
33 | 38 | | |
34 | | - | |
35 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
| |||
0 commit comments