Repository navigation
Commit 59428c4
committed
fix(app): drop inline theme-preload substitution to satisfy CSP
The opencode-desktop:theme-preload vite plugin rewrote the canonical
external `<script src="/oc-theme-preload.js">` form into an inline
script at build time, trading a sub-millisecond round-trip on
localhost for inline-script CSP friction. With our embedded server's
strict CSP (`script-src 'self' 'wasm-unsafe-eval'`), the inline
form is blocked at runtime: theme preload silently does not run, and
the console shows "Executing inline script violates the following
Content Security Policy directive".
Drop the inline-substitution plugin. The source `index.html` already
declares the external form on line 19, so removing the plugin lets
that canonical form survive into `dist/index.html`. The external
script still runs synchronously in <head> before the bundle, so theme
load order is preserved; only the small fetch round-trip is added.
Alternatives considered:
- SHA-256 hash in CSP - brittle; any edit to the preload script
silently breaks theme preload until the hash is regenerated, with no
test that would catch it.
- 'unsafe-inline' - defeats most of CSP's value.
- Per-response nonce - requires server-side HTML rewriting on every
GET; heavy for a tiny gain on a single-tenant tool.
Refs upstream PR anomalyco#18985 (the inline substitution).
Refs upstream issue anomalyco#18325 (the auth-loop bug that
surfaced this CSP regression).1 parent 4eb970c commit 59428c4
1 file changed
Lines changed: 7 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
6 | | - | |
7 | | - | |
8 | 5 | | |
9 | 6 | | |
10 | 7 | | |
| |||
24 | 21 | | |
25 | 22 | | |
26 | 23 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
36 | 31 | | |
37 | 32 | | |
38 | 33 | | |
0 commit comments