Force APIs to use SSR instead of static generation #4

Merged
DorianNiemiecSVRJS merged 1 commit from main into main 2024-06-22 12:26:11 +02:00
8 changed files with 24 additions and 0 deletions

View file

@ -1,6 +1,9 @@
import { NextRequest, NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
import clientPromise from "@/lib/db"; import clientPromise from "@/lib/db";
// Force the API to use SSR instead of static generation
export const dynamic = "force-dynamic";
// Handler for GET requests // Handler for GET requests
export async function GET(req: NextRequest) { export async function GET(req: NextRequest) {
try { try {

View file

@ -1,6 +1,9 @@
import { NextRequest, NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
import { serialize } from "cookie"; 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) { export async function POST(request: NextRequest) {
const { username, password } = await request.json(); const { username, password } = await request.json();

View file

@ -1,6 +1,9 @@
import { NextRequest, NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
import clientPromise from "@/lib/db"; import clientPromise from "@/lib/db";
// Force the API to use SSR instead of static generation
export const dynamic = "force-dynamic";
// Handler for GET requests // Handler for GET requests
export async function GET(req: NextRequest) { export async function GET(req: NextRequest) {
try { try {

View file

@ -1,6 +1,9 @@
import { NextRequest, NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
import clientPromise from "@/lib/db"; import clientPromise from "@/lib/db";
// Force the API to use SSR instead of static generation
export const dynamic = "force-dynamic";
// Handler for GET requests // Handler for GET requests
export async function GET(req: NextRequest) { export async function GET(req: NextRequest) {
try { try {

View file

@ -1,6 +1,9 @@
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import clientPromise from "@/lib/db"; 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) { export async function POST(request: Request) {
const body = await request.json(); const body = await request.json();
const { fileName, version, downloadLink, fileSize } = body; const { fileName, version, downloadLink, fileSize } = body;

View file

@ -1,6 +1,9 @@
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import clientPromise from "@/lib/db"; 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) { export async function POST(request: Request) {
const body = await request.json(); const body = await request.json();
const { fileName, version, downloadLink, fileSize } = body; const { fileName, version, downloadLink, fileSize } = body;

View file

@ -1,6 +1,9 @@
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import clientPromise from "@/lib/db"; 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) { export async function POST(request: Request) {
const body = await request.json(); const body = await request.json();
const { fileName, version, downloadLink, fileSize } = body; const { fileName, version, downloadLink, fileSize } = body;

View file

@ -1,6 +1,9 @@
import { createRouteHandler } from "uploadthing/next"; import { createRouteHandler } from "uploadthing/next";
import { ourFileRouter } from "./core"; import { ourFileRouter } from "./core";
// Force the API to use SSR instead of static generation
export const dynamic = "force-dynamic";
export const { GET, POST } = createRouteHandler({ export const { GET, POST } = createRouteHandler({
router: ourFileRouter, router: ourFileRouter,
}); });