diff --git a/backend/src/app/api/auth/about-me/route.ts b/backend/src/app/api/auth/about-me/route.ts index 587daf5..11de776 100644 --- a/backend/src/app/api/auth/about-me/route.ts +++ b/backend/src/app/api/auth/about-me/route.ts @@ -30,5 +30,14 @@ export async function POST(request: NextRequest) { return rateLimit.sendResponse({ error: "Failed to update description" }, 500); } + // Tell Cloudflare to purge cache + fetch(`https://api.cloudflare.com/client/v4/zones/${process.env.CLOUDFLARE_ZONE_ID}/purge_cache`, { + method: "POST", + headers: { Authorization: `Bearer ${process.env.CLOUDFLARE_API_TOKEN}`, "Content-Type": "application/json" }, + body: JSON.stringify({ + files: [`${process.env.NEXT_PUBLIC_BASE_URL}/api/profile/${session.user?.id}/info`], + }), + }); + return rateLimit.sendResponse({ success: true }); } diff --git a/backend/src/app/api/auth/name/route.ts b/backend/src/app/api/auth/name/route.ts index 8a9af28..3998404 100644 --- a/backend/src/app/api/auth/name/route.ts +++ b/backend/src/app/api/auth/name/route.ts @@ -33,5 +33,14 @@ export async function POST(request: NextRequest) { return rateLimit.sendResponse({ error: "Failed to update name" }, 500); } + // Tell Cloudflare to purge cache + fetch(`https://api.cloudflare.com/client/v4/zones/${process.env.CLOUDFLARE_ZONE_ID}/purge_cache`, { + method: "POST", + headers: { Authorization: `Bearer ${process.env.CLOUDFLARE_API_TOKEN}`, "Content-Type": "application/json" }, + body: JSON.stringify({ + files: [`${process.env.NEXT_PUBLIC_BASE_URL}/api/profile/${session.user.id}/info`], + }), + }); + return rateLimit.sendResponse({ success: true }); } diff --git a/backend/src/app/api/auth/picture/route.ts b/backend/src/app/api/auth/picture/route.ts index c5f5775..bbaae8e 100644 --- a/backend/src/app/api/auth/picture/route.ts +++ b/backend/src/app/api/auth/picture/route.ts @@ -81,5 +81,17 @@ export async function POST(request: NextRequest) { return rateLimit.sendResponse({ error: "Failed to update profile picture" }, 500); } + // Tell Cloudflare to purge cache + fetch(`https://api.cloudflare.com/client/v4/zones/${process.env.CLOUDFLARE_ZONE_ID}/purge_cache`, { + method: "POST", + headers: { Authorization: `Bearer ${process.env.CLOUDFLARE_API_TOKEN}`, "Content-Type": "application/json" }, + body: JSON.stringify({ + files: [ + `${process.env.NEXT_PUBLIC_BASE_URL}/api/profile/${session.user?.id}/info`, + `${process.env.NEXT_PUBLIC_BASE_URL}/profile/${session.user?.id}/picture`, + ], + }), + }); + return rateLimit.sendResponse({ success: true }); } diff --git a/backend/src/app/api/mii/[id]/edit/route.ts b/backend/src/app/api/mii/[id]/edit/route.ts index 7de330a..9b7382a 100644 --- a/backend/src/app/api/mii/[id]/edit/route.ts +++ b/backend/src/app/api/mii/[id]/edit/route.ts @@ -266,9 +266,12 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{ headers: { Authorization: `Bearer ${process.env.CLOUDFLARE_API_TOKEN}`, "Content-Type": "application/json" }, body: JSON.stringify({ files: [ - `${process.env.NEXT_PUBLIC_BASE_URL}/mii/${miiId}`, + `${process.env.NEXT_PUBLIC_BASE_URL}/api/mii/${miiId}/info`, `${process.env.NEXT_PUBLIC_BASE_URL}/mii/${miiId}/image?type=mii`, `${process.env.NEXT_PUBLIC_BASE_URL}/mii/${miiId}/image?type=features`, + `${process.env.NEXT_PUBLIC_BASE_URL}/mii/${miiId}/image?type=image0`, + `${process.env.NEXT_PUBLIC_BASE_URL}/mii/${miiId}/image?type=image1`, + `${process.env.NEXT_PUBLIC_BASE_URL}/mii/${miiId}/image?type=image2`, ], }), }).catch((err) => {