this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(manage): proxy bsky-prefill avatar through /api/me/avatar

Embedding the raw PDS getBlob URL in an <img> tag was producing a
broken image preview in the manage form for users without a registry
record yet. Some PDS hosts don't serve blobs cleanly to a browser
(content-type, redirects, CORS quirks), but they all work fine for a
server-to-server fetch.

We already have /api/me/avatar that proxies the bsky avatar through
this server with a friendly content-type and cache headers, including
the prefill fallback for users with no registry profile yet. Point
initialAvatarUrl at it instead of the direct PDS URL.

Made-with: Cursor

+9 -9
+9 -9
routes/explore/manage.tsx
··· 8 8 import { loadSession } from "../../lib/oauth.ts"; 9 9 import { getBskyProfile } from "../../lib/pds.ts"; 10 10 11 + /** Route the prefill avatar through our own proxy (which streams the 12 + * PDS blob with friendly content-type + cache headers) rather than 13 + * embedding the raw PDS getBlob URL into an <img>. Some PDS hosts 14 + * don't serve blobs cleanly to a browser <img> tag (content-type, 15 + * redirects, CORS quirks), but they all work fine for a server-to- 16 + * server fetch. */ 17 + const ME_AVATAR_PROXY = "/api/me/avatar"; 18 + 11 19 export const handler = define.handlers({ 12 20 async GET(ctx) { 13 21 const user = ctx.state.user; ··· 73 81 license: null, 74 82 }; 75 83 if (bsky.avatar) { 76 - const cid = bsky.avatar.ref.$link; 77 - const u = new URL( 78 - `${ 79 - session.pdsUrl.replace(/\/$/, "") 80 - }/xrpc/com.atproto.sync.getBlob`, 81 - ); 82 - u.searchParams.set("did", user.did); 83 - u.searchParams.set("cid", cid); 84 - initialAvatarUrl = u.toString(); 84 + initialAvatarUrl = ME_AVATAR_PROXY; 85 85 } 86 86 } 87 87 }