Skip to content

Commit f83a936

Browse files
committed
fix(media): preserve fallback expansion and rejection headers
1 parent 6b1d1ba commit f83a936

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎apps/server/src/assets/GitHubMediaFetch.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,19 @@ export const githubMediaResponse = Effect.fn("GitHubMediaFetch.githubMediaRespon
173173
headers,
174174
});
175175
}
176-
for (const name of FORWARDED_RESPONSE_HEADERS) {
177-
const value = response.headers[name];
178-
if (value !== undefined) headers[name] = value;
179-
}
180176
// Only pictures and recordings leave this origin, and never on GitHub's word alone: the raw
181177
// host labels every committed binary `application/octet-stream`, so the name decides those.
182-
const upstreamType = headers["content-type"]?.split(";", 1)[0]?.trim().toLowerCase() ?? "";
178+
const upstreamType = response.headers["content-type"]?.split(";", 1)[0]?.trim().toLowerCase() ?? "";
183179
const contentType = MEDIA_CONTENT_TYPE_PATTERN.test(upstreamType)
184180
? upstreamType
185181
: (Mime.getType(githubMediaFileName(asset.url))?.toLowerCase() ?? "");
186182
if (!MEDIA_CONTENT_TYPE_PATTERN.test(contentType)) {
187183
return HttpServerResponse.empty({ status: 415, headers });
188184
}
185+
for (const name of FORWARDED_RESPONSE_HEADERS) {
186+
const value = response.headers[name];
187+
if (value !== undefined) headers[name] = value;
188+
}
189189
headers["content-type"] = contentType;
190190
if (contentType === SVG_CONTENT_TYPE) {
191191
headers["content-security-policy"] = SVG_CONTENT_SECURITY_POLICY;

‎apps/web/src/components/ChatMarkdown.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,9 @@ export const ChatMarkdownAssetImage = memo(function ChatMarkdownAssetImage(props
16411641
kind: props.kind ?? "image",
16421642
name: props.alt || (props.kind ?? "image"),
16431643
src,
1644-
asset: { environmentId: props.environmentId, resource },
1644+
...(fallbackSrc === undefined
1645+
? { asset: { environmentId: props.environmentId, resource } }
1646+
: {}),
16451647
...(reference ? { reference } : {}),
16461648
...(relativePath && (resource._tag === "media-file" || resource._tag === "workspace-file")
16471649
? {

0 commit comments

Comments
 (0)