fix: allow Origin: null for /api/asset-cache in sandboxed plugin previews#4487
Conversation
|
Thanks for the clear repro and test seam here, @daltonnyx. @mrcfps this PR's current head |
PerishCode
left a comment
There was a problem hiding this comment.
@daltonnyx I reviewed the origin-validation middleware change and the regression coverage for /api/asset-cache with Origin: null. The diff stays scoped to the sandboxed read-only GET allowlist while preserving rejection for mutating and non-allowlisted API routes, and the current PR checks are green. Nice work keeping this fix tight and tied to the Docker preview failure.
|
Hi @daltonnyx! Your first Open Design PR has been merged! Huge thanks for jumping in and improving the project! You contributed: Merged PR: #4487 fix: allow Origin: null for /api/asset-cache in sandboxed plugin previews This landed in the daemon/server path around sandboxed preview behavior, so you already have context on backend request handling and edge-case validation in this codebase. For your next contribution, we picked two issues that look like a good follow-up:
This is a good fit because it stays close to runtime/server edge cases and debugging environment-specific behavior.
This is a good fit because it also lives in the daemon/backend surface and benefits from careful request-path and failure-mode reasoning. If one of these looks interesting, feel free to comment /claim on the issue and we will help you get started! Once your second PR gets merged, you will move into our Continuous Contributor tier. We are also starting to highlight repeat contributors more actively in the community, so this is a great time to keep going! Thanks again for the first PR, and welcome to the Open Design contributor community! The Open Design team P.S. We hang out in Discord — come say hi: https://discord.gg/3C6EWXbdQQ |
Why
When running Open Design in Docker, plugin preview HTML is served inside a sandboxed iframe. The iframe loads external media assets (images/videos) through the same-origin proxy route
/api/asset-cache?url=<encoded>. Because the iframe is sandboxed, the browser sendsOrigin: nullwith the request. The daemon origin-validation middleware rejectedOrigin: nullfor/api/asset-cachebecause it was not in the safe read-only GET allowlist, returning a403. This worked fine in dev mode (pnpm tools-dev run web) because the dev path often usessrcDocor raw project file routes that were already allowed.What users will see
Plugin preview cards and detail pages in Docker/production now correctly load external media assets (Cloudinary images, Higgs videos, etc.) instead of showing broken images with a CSP
img-srcviolation.Surface area
apps/weborapps/desktop(including Electron menu bar)odsubcommand or flag, newtools-dev/tools-pack/tools-prflag, or newOD_*env var/api/*endpoint, new SSE event, or changed shape inpackages/contractsskills/,design-systems/,design-templates/, orcraft/, or change to the skills protocolTRANSLATIONS.mdfor the locale workflow)package.json(dependenciesordevDependencies); workspace-packagepackage.jsonfiles are out of scope. Include a paragraph on what we get vs. what bytes we ship (seeCONTRIBUTING.md→ Code style)Screenshots
Before
After
Bug fix verification
apps/daemon/tests/origin-validation.test.ts— new test caseallows Origin: null for GET asset-cache routesmainand green on this branch? (yes / no) yes — added a fake/api/asset-cacheroute to the test app, assertedGET /api/asset-cache?...withOrigin: nullreturns200; would fail onmainwhere_NULL_ORIGIN_SAFE_GET_REdoes not include/asset-cache403Validation
pnpm --filter @open-design/daemon exec tsc -p tsconfig.tests.json --noEmit --pretty false— passed/api/asset-cacheroute without CSP errors