Skip to content

fix(web): set explicit content headers on proxied storage responses - #2996

Merged
richiemcilroy merged 2 commits into
mainfrom
fix/storage-proxy-response-headers
Oct 23, 2026
Merged

richiemcilroy merged 2 commits into
mainfrom
fix/storage-proxy-response-headers

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Responses that /api/storage/object streams from storage now always send X-Content-Type-Options: nosniff and a sandbox; default-src 'none' CSP. The upstream Content-Type is only passed through when it is one of the media, image, caption, playlist or JSON types this route serves; anything else is sent as application/octet-stream with Content-Disposition: attachment. The HEAD branch follows the same rules, and the redirect and internal download branches are unchanged.

Testing

  • bun run biome check --write on the touched files
  • npx vitest run for storage-object-response-headers, storage-object-verification, storage-object-route, playback-source and mp4-level-patch (90 passed)
  • cd apps/web && npx tsc --noEmit (clean)

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with the previous test issue fixed and no new findings.

Summary

Adds explicit content headers to storage responses.

  • Proxied storage responses keep known media inline and download the rest.

Reviews (2) · Last reviewed commit: "test(web): exercise missing content type..." · Reviewed by Greptile

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

Open in Capy

const upstream = (contentType: string | null, init: ResponseInit = {}) => {
const headers = new Headers(init.headers);
if (contentType) headers.set("Content-Type", contentType);
return new Response("data", { status: init.status ?? 200, headers });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing-header case repeats plain text

upstream(null) does not produce a response without Content-Type. new Response("data", ...) automatically adds text/plain;charset=UTF-8, so this repeats the plain-text case and leaves the missing-header fallback untested. Delete Content-Type from the constructed response when the input is null, then assert it is absent before calling GET.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/__tests__/unit/storage-object-response-headers.test.ts
Line: 54

Comment:
**Missing-header case repeats plain text**

`upstream(null)` does not produce a response without `Content-Type`. `new Response("data", ...)` automatically adds `text/plain;charset=UTF-8`, so this repeats the plain-text case and leaves the missing-header fallback untested. Delete `Content-Type` from the constructed response when the input is `null`, then assert it is absent before calling `GET`.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@vercel
vercel Bot temporarily deployed to Preview – cap-status October 23, 2026 15:54 Inactive
@vercel

vercel Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Oct 23, 2026 3:54pm UTC

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

@richiemcilroy
richiemcilroy merged commit 1be3e4c into main Oct 23, 2026
38 checks passed

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cap-web — 49a257ad Deployed Oct 23, 2026 by vercel[bot]
Preview – cap-status — 49a257ad Deployed Oct 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant