Skip to content

Commit 904dd67

Browse files
committed
fix(api-docs): serve Redoc from self rather than CDN to avoid CSP issues
Downloading redoc.standalone.js at build time (CI) and local dev (proto:generate) so it is served from 'self', which the existing Flutter CSP already allows. Removes the /api-docs/* CSP override that was added to permit cdn.jsdelivr.net. https://claude.ai/code/session_015uTnGiC56cEELZMH2cQQU4
1 parent b8fe17e commit 904dd67

5 files changed

Lines changed: 4 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ jobs:
200200
setup_only: true
201201
- run: cd proto && buf generate
202202
- run: cp docs/code/api/openapi/openapi.yaml web/api-docs/openapi.yaml
203+
- run: curl -sLo web/api-docs/redoc.standalone.js https://cdn.jsdelivr.net/npm/redoc@2.4.0/bundles/redoc.standalone.js
203204

204205
- name: Get git version info
205206
id: git_version

mise.dev.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ dir = "proto"
4646
run = """
4747
buf generate
4848
cp ../docs/code/api/openapi/openapi.yaml ../web/api-docs/openapi.yaml
49+
curl -sLo ../web/api-docs/redoc.standalone.js https://cdn.jsdelivr.net/npm/redoc@2.4.0/bundles/redoc.standalone.js
4950
"""
5051

5152
[tasks."proto:clients"]

web/_headers

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@
1616
Referrer-Policy: strict-origin-when-cross-origin
1717
Strict-Transport-Security: max-age=31536000; includeSubDomains
1818

19-
# API docs — relaxed CSP to allow Redoc from jsDelivr CDN.
20-
# This path serves developer documentation, not the Flutter app.
21-
/api-docs/*
22-
Content-Security-Policy: default-src 'self'; base-uri 'self'; frame-ancestors 'none'; object-src 'none'; script-src 'self' https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https:; font-src 'self' data: https:; connect-src 'self'; worker-src 'self' blob:;
23-
X-Content-Type-Options: nosniff
24-
X-Frame-Options: DENY
25-
Referrer-Policy: strict-origin-when-cross-origin
26-
Strict-Transport-Security: max-age=31536000; includeSubDomains
27-
2819
# Production Environment - Explicit domain rule for clarity
2920
# Custom domain: cambeerfestival.app
3021
# Path-based rules below apply to this domain for performance optimization

web/api-docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Generated in CI (build-web job) and locally via: MISE_ENV=dev ./bin/mise run proto:generate
22
openapi.yaml
3+
redoc.standalone.js

web/api-docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
expand-responses="200"
1919
required-props-first="true"
2020
></redoc>
21-
<script src="https://cdn.jsdelivr.net/npm/redoc@2.4.0/bundles/redoc.standalone.js"></script>
21+
<script src="redoc.standalone.js"></script>
2222
</body>
2323
</html>

0 commit comments

Comments
 (0)