From ca173be65185fa23a10c7672f2cfc4314bfb8580 Mon Sep 17 00:00:00 2001 From: Bhavya Gor Date: Wed, 14 May 2025 20:24:32 +0530 Subject: [PATCH 1/3] try svg --- frontend/src/app/api/svg/route.ts | 34 +++++++++++++++++++++++++++++++ frontend/src/app/page.tsx | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 frontend/src/app/api/svg/route.ts diff --git a/frontend/src/app/api/svg/route.ts b/frontend/src/app/api/svg/route.ts new file mode 100644 index 0000000..79ab05a --- /dev/null +++ b/frontend/src/app/api/svg/route.ts @@ -0,0 +1,34 @@ +import { NextResponse } from "next/server"; + +export const dynamic = "force-dynamic"; // ensure it's not cached if needed + +export async function GET() { + const res = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/app/get-subscriber-count`); + const data = await res.json(); + const subCount = data.result.data ?? 0; + + const svg = ` + + + + + + + + + + + + ${subCount} users + + + `.trim(); + + return new NextResponse(svg, { + status: 200, + headers: { + "Content-Type": "image/svg+xml", + "Cache-Control": "no-cache", + }, + }); +} diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index 2ad41f8..f617ddd 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -10,7 +10,7 @@ const iconUrl = `${appUrl}/logo_replyguy.png`; const framePreviewMetadata = { version: "next", - imageUrl: `${appUrl}/full_logo.png`, + imageUrl: `${appUrl}/api/svg`, iconUrl, heroImageUrl: `${appUrl}/full_logo.png`, button: { From fb64327bd280e1ecab8b7363290408c843de9fe1 Mon Sep 17 00:00:00 2001 From: Bhavya Gor Date: Wed, 14 May 2025 20:38:29 +0530 Subject: [PATCH 2/3] added caching --- frontend/src/app/api/svg/route.ts | 8 ++++---- frontend/src/lib/utils.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/api/svg/route.ts b/frontend/src/app/api/svg/route.ts index 79ab05a..0167aff 100644 --- a/frontend/src/app/api/svg/route.ts +++ b/frontend/src/app/api/svg/route.ts @@ -1,9 +1,9 @@ import { NextResponse } from "next/server"; -export const dynamic = "force-dynamic"; // ensure it's not cached if needed - export async function GET() { - const res = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/app/get-subscriber-count`); + const res = await fetch( + `${process.env.NEXT_PUBLIC_BACKEND_URL}/api/app/get-subscriber-count`, + ); const data = await res.json(); const subCount = data.result.data ?? 0; @@ -28,7 +28,7 @@ export async function GET() { status: 200, headers: { "Content-Type": "image/svg+xml", - "Cache-Control": "no-cache", + "Cache-Control": "public, max-age=3600", }, }); } diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index 8743edf..e6f4343 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -116,7 +116,7 @@ export async function getFarcasterMetadata(): Promise { ? `https://api.neynar.com/f/app/${neynarClientId}/event` : `${appUrl}/api/webhook`; - const imageUrl = `${appUrl}/full_logo.png`; + const imageUrl = `${appUrl}/api/svg`; const logoUrl = `${appUrl}/logo.png`; const description = "Get the most relevant content discovery on your each cast."; From eb1215140ea9a440e72229ab1d64b07d8064e74c Mon Sep 17 00:00:00 2001 From: Bhavya Gor Date: Wed, 14 May 2025 20:50:17 +0530 Subject: [PATCH 3/3] revertings --- frontend/src/lib/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index e6f4343..8743edf 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -116,7 +116,7 @@ export async function getFarcasterMetadata(): Promise { ? `https://api.neynar.com/f/app/${neynarClientId}/event` : `${appUrl}/api/webhook`; - const imageUrl = `${appUrl}/api/svg`; + const imageUrl = `${appUrl}/full_logo.png`; const logoUrl = `${appUrl}/logo.png`; const description = "Get the most relevant content discovery on your each cast.";