[Server.py] Update CSP to allow blob: and data: - #15565
Conversation
Fix for `Record Audio` node not working caused by restrictive CSP policies when enabling --disable-api-url
|
✅ All contributors have signed the CLA. Thank you! This PR is ready to be merged. |
|
I have read and agree to the Contributor License Agreement |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📜 Recent review details
|
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly summarizes the CSP change to allow blob: and data: sources. |
| Description check | ✅ Passed | The description explains the CSP problem and the fix for frontend media playback and file uploads. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
- Create stacked PR
- Commit on current branch
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Summary
Fixes media playback and file upload failures in the frontend when running with
--disable-api-nodes.For example the
Record Audionode.Problem
When
--disable-api-nodesis enabled,create_block_external_middlewareapplies a restrictive Content Security Policy. The current policy omitsblob:fromconnect-srcand lacks an explicitmedia-srcdirective (which falls back todefault-src 'self').As a result, frontend nodes handling audio and video uploads fail when trying to fetch or play back client-side
blob:URLs, throwing browser CSP violation errors.Solution
Add
blob:toconnect-srcand definemedia-src 'self' data: blob:;in the CSP header.This allows the UI to process audio/video buffers created by the browser while still respecting the goal of the
--disable-api-nodesflag.