tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
291
fork
atom
a tool for shared writing and social publishing
291
fork
atom
overview
issues
28
pulls
pipelines
return fallback icon and fix cache-control directive
awarm.space
6 months ago
8dad9438
77faadfd
+3
-2
1 changed file
expand all
collapse all
unified
split
app
lish
[did]
[publication]
icon.ts
+3
-2
app/lish/[did]/[publication]/icon.ts
···
4
4
import { PubLeafletPublication } from "lexicons/api";
5
5
import { supabaseServerClient } from "supabase/serverClient";
6
6
import sharp from "sharp";
7
7
+
import { redirect } from "next/navigation";
7
8
8
9
let idResolver = new IdResolver();
9
10
···
40
41
.single();
41
42
42
43
let record = publication?.record as PubLeafletPublication.Record | null;
43
43
-
if (!record?.icon) return null;
44
44
+
if (!record?.icon) return redirect("/icon.png");
44
45
45
46
let identity = await idResolver.did.resolve(did);
46
47
let service = identity?.service?.find((f) => f.id === "#atproto_pds");
···
58
59
return new Response(new Uint8Array(resizedImage), {
59
60
headers: {
60
61
"Content-Type": "image/png",
61
61
-
"CDN-Cache-Control": "s-max-age=86400, stale-while-revalidate=86400",
62
62
+
"CDN-Cache-Control": "s-maxage=86400, stale-while-revalidate=86400",
62
63
"Cache-Control": "public, max-age=3600",
63
64
},
64
65
});