From eaf74b903cc750f6f83063ec2053a3a6e01a183e Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sat, 22 Jun 2024 11:57:32 +0200 Subject: [PATCH] Force APIs to use SSR instead of static generation --- app/api/downloads/route.ts | 3 +++ app/api/login/route.ts | 3 +++ app/api/logs/route.ts | 3 +++ app/api/mods/route.ts | 3 +++ app/api/upload/route.ts | 3 +++ app/api/uploadlogs/route.ts | 3 +++ app/api/uploadmods/route.ts | 3 +++ app/api/uploadthing/route.ts | 3 +++ 8 files changed, 24 insertions(+) diff --git a/app/api/downloads/route.ts b/app/api/downloads/route.ts index f3f80b5..5326cfa 100644 --- a/app/api/downloads/route.ts +++ b/app/api/downloads/route.ts @@ -1,6 +1,9 @@ import { NextRequest, NextResponse } from "next/server"; import clientPromise from "@/lib/db"; +// Force the API to use SSR instead of static generation +export const dynamic = "force-dynamic"; + // Handler for GET requests export async function GET(req: NextRequest) { try { diff --git a/app/api/login/route.ts b/app/api/login/route.ts index 0e7583e..8c90c44 100644 --- a/app/api/login/route.ts +++ b/app/api/login/route.ts @@ -1,6 +1,9 @@ import { NextRequest, NextResponse } from "next/server"; import { serialize } from "cookie"; +// Force the API to use SSR instead of static generation +export const dynamic = "force-dynamic"; + export async function POST(request: NextRequest) { const { username, password } = await request.json(); diff --git a/app/api/logs/route.ts b/app/api/logs/route.ts index 76d777a..f9b1049 100644 --- a/app/api/logs/route.ts +++ b/app/api/logs/route.ts @@ -1,6 +1,9 @@ import { NextRequest, NextResponse } from "next/server"; import clientPromise from "@/lib/db"; +// Force the API to use SSR instead of static generation +export const dynamic = "force-dynamic"; + // Handler for GET requests export async function GET(req: NextRequest) { try { diff --git a/app/api/mods/route.ts b/app/api/mods/route.ts index 172e6e2..e7475ab 100644 --- a/app/api/mods/route.ts +++ b/app/api/mods/route.ts @@ -1,6 +1,9 @@ import { NextRequest, NextResponse } from "next/server"; import clientPromise from "@/lib/db"; +// Force the API to use SSR instead of static generation +export const dynamic = "force-dynamic"; + // Handler for GET requests export async function GET(req: NextRequest) { try { diff --git a/app/api/upload/route.ts b/app/api/upload/route.ts index abe2283..fb95372 100644 --- a/app/api/upload/route.ts +++ b/app/api/upload/route.ts @@ -1,6 +1,9 @@ import { NextResponse } from "next/server"; import clientPromise from "@/lib/db"; +// Force the API to use SSR instead of static generation +export const dynamic = "force-dynamic"; + export async function POST(request: Request) { const body = await request.json(); const { fileName, version, downloadLink, fileSize } = body; diff --git a/app/api/uploadlogs/route.ts b/app/api/uploadlogs/route.ts index 2bc660d..91871b6 100644 --- a/app/api/uploadlogs/route.ts +++ b/app/api/uploadlogs/route.ts @@ -1,6 +1,9 @@ import { NextResponse } from "next/server"; import clientPromise from "@/lib/db"; +// Force the API to use SSR instead of static generation +export const dynamic = "force-dynamic"; + export async function POST(request: Request) { const body = await request.json(); const { fileName, version, downloadLink, fileSize } = body; diff --git a/app/api/uploadmods/route.ts b/app/api/uploadmods/route.ts index 230fcc0..dca0429 100644 --- a/app/api/uploadmods/route.ts +++ b/app/api/uploadmods/route.ts @@ -1,6 +1,9 @@ import { NextResponse } from "next/server"; import clientPromise from "@/lib/db"; +// Force the API to use SSR instead of static generation +export const dynamic = "force-dynamic"; + export async function POST(request: Request) { const body = await request.json(); const { fileName, version, downloadLink, fileSize } = body; diff --git a/app/api/uploadthing/route.ts b/app/api/uploadthing/route.ts index f8f1912..0d0788d 100644 --- a/app/api/uploadthing/route.ts +++ b/app/api/uploadthing/route.ts @@ -1,6 +1,9 @@ import { createRouteHandler } from "uploadthing/next"; import { ourFileRouter } from "./core"; +// Force the API to use SSR instead of static generation +export const dynamic = "force-dynamic"; + export const { GET, POST } = createRouteHandler({ router: ourFileRouter, }); -- 2.39.5