a tool for shared writing and social publishing
0
fork

Configure Feed

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

cache image responses

+12 -1
+12 -1
app/api/atproto_images/route.ts
··· 16 16 let service = identity?.service?.find((f) => f.id === "#atproto_pds"); 17 17 console.log(identity); 18 18 if (!service) return new NextResponse(null, { status: 404 }); 19 - return fetch( 19 + const response = await fetch( 20 20 `${service.serviceEndpoint}/xrpc/com.atproto.sync.getBlob?did=${params.did}&cid=${params.cid}`, 21 21 ); 22 + 23 + // Clone the response to modify headers 24 + const cachedResponse = new Response(response.body, response); 25 + 26 + // Set cache-control header to cache indefinitely 27 + cachedResponse.headers.set( 28 + "Cache-Control", 29 + "public, max-age=31536000, immutable", 30 + ); 31 + 32 + return cachedResponse; 22 33 }