diff --git a/next.config.ts b/next.config.ts index f7158ac..8114235 100644 --- a/next.config.ts +++ b/next.config.ts @@ -5,6 +5,17 @@ const nextConfig: NextConfig = { images: { unoptimized: true, }, + async headers() { + return [ + { + // Prevent Cloudflare from serving cached HTML for RSC navigation requests + source: "/:path*", + headers: [ + { key: "Vary", value: "RSC, Next-Router-State-Tree, Next-Router-Prefetch" }, + ], + }, + ]; + }, }; export default nextConfig; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index cfc142b..c3cc1cc 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -104,6 +104,7 @@ model Mii { @@index([gender]) @@index([makeup]) @@index([quarantined, id]) + @@index([in_queue, quarantined, createdAt(sort: Desc)]) @@map("miis") } diff --git a/src/components/mii/list/index.tsx b/src/components/mii/list/index.tsx index 6d1485f..8fb5afa 100644 --- a/src/components/mii/list/index.tsx +++ b/src/components/mii/list/index.tsx @@ -108,7 +108,6 @@ export default async function MiiList({ searchParams, userId, parentPage }: Prop const skip = (page - 1) * limit; let totalCount: number; - let filteredCount: number; let miis: Prisma.MiiGetPayload<{ select: typeof select }>[]; if (sort === "random") { @@ -119,7 +118,6 @@ export default async function MiiList({ searchParams, userId, parentPage }: Prop }); totalCount = matchingIds.length; - filteredCount = Math.max(0, Math.min(limit, totalCount - skip)); if (matchingIds.length === 0) return; @@ -155,14 +153,13 @@ export default async function MiiList({ searchParams, userId, parentPage }: Prop orderBy = [{ createdAt: "desc" }, { name: "asc" }]; } - [totalCount, filteredCount, miis] = await Promise.all([ + [totalCount, miis] = await Promise.all([ prisma.mii.count({ where: { ...where, userId } }), - prisma.mii.count({ where, skip, take: limit }), prisma.mii.findMany({ where, orderBy, select, - skip: (page - 1) * limit, + skip, take: limit, }), ]); @@ -174,19 +171,8 @@ export default async function MiiList({ searchParams, userId, parentPage }: Prop
- {totalCount == filteredCount ? ( - <> - {totalCount} - {totalCount === 1 ? "Mii" : "Miis"} - - ) : ( - <> - {filteredCount} - of - {totalCount} - Miis - - )} + {totalCount} + {totalCount === 1 ? "Mii" : "Miis"}
diff --git a/src/lib/rate-limit.ts b/src/lib/rate-limit.ts index 6788127..b8a53c4 100644 --- a/src/lib/rate-limit.ts +++ b/src/lib/rate-limit.ts @@ -68,9 +68,10 @@ export class RateLimit { return { success, limit: this.maxRequests, remaining, expires: expireAt }; } catch (error) { + // Fail open — don't block users when Redis is unreachable console.error("Rate limit check failed", error); return { - success: false, + success: true, limit: this.maxRequests, remaining: this.maxRequests, expires: expireAt,