Repository navigation
Zeta 后端:CSP connect-src 放行 R2 存储 host(修复浏览器直传被拦) - #273
Merged
todosdev[bot] merged 1 commit intoNov 30, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
connect-src 'self'阻断浏览器直传 R2 预签名 URL 的问题(QA Update CodeMirror packages #60 唯一失败项 ①)。connect-src由静态'self'改为动态追加精确账号级 R2 host,白名单窄而不宽。Changes
worker/src/middleware/security.tsr2Host(复用worker/src/lib/r2-presign.ts,与预签名 URL 同源)。connect-src从'self'改为'self' https://<CF_ACCOUNT_ID>.r2.cloudflarestorage.com;R2 未配置(CF_ACCOUNT_ID缺失或为*_PLACEHOLDER)时退回'self',与上传接口 fail-closed 返回 503 的既有行为一致。/spark-ui、/spark-history、/spark-worker代理分支不动,它们不做 jar 直传),未改其他 CSP 指令。worker/src/routes/__tests__/app.test.tsconnect-src含精确账号 host;未配置态connect-src保持'self'。Testing
cd worker && pnpm type-check—— 通过(退出码 0)。cd worker && pnpm vitest run src/routes/__tests__/app.test.ts—— 15/15 通过。cd worker && pnpm vitest run --exclude '**/*live*.test.ts'—— 61 文件 / 1190 用例全绿。pnpm lint、pnpm format:check—— 通过。说明:全量
pnpm test中spark-live/spark-cancel-live共 9 条 live 用例失败,报错为 Spark 机不可达,属沙箱注入SPARK_ACCESS指向不可达实例的环境问题,与本改动无关;CI 不注入这些 live 凭证,会自行 skip。