next doesn't get updated until redeploy
Unanswered
Asiatic Lion posted this in #help-forum
Asiatic LionOP
all of my api with
get
doesn't get update with netlify but post
request seems to work. but redeploying my app causes it to update// api/thoughts
import { type NextRequest, NextResponse } from "next/server";
import { ZodError } from "zod";
import { prisma } from "@/lib/db";
import IError from "@/types/error";
import { THOUGHTS_PER_PAGE } from "@/config/thought";
export const dynamic = "force-dynamic";
export async function GET(req: NextRequest) {
const searchParams = req.nextUrl.searchParams;
const searchTerm = searchParams.get("searchTerm");
const lastId = searchParams.get("lastId");
try {
const thoughts = await prisma.thought.findMany({
take: THOUGHTS_PER_PAGE,
skip: lastId ? 1 : 0,
cursor: lastId
? {
id: lastId,
}
: undefined,
where: searchTerm
? {
author: {
contains: searchTerm,
mode: "insensitive",
},
}
: undefined,
orderBy: {
createdAt: "desc",
},
});
return NextResponse.json(thoughts, { status: 200 });
} catch (error) {
// error handling logic
}
}
export async function POST(req: Request) {
try {
const { author, message, color } = await req.json();
await prisma.thought.create({
data: {
author,
message,
color,
},
});
return NextResponse.json(
{
message: "Thought submitted successfully",
},
{ status: 201 },
);
} catch (error) {
// error handling logic
}
}
1 Reply
Asiatic LionOP
"dependencies": {
"@2toad/profanity": "^3.1.1",
"@mantine/core": "^7.17.2",
"@mantine/form": "^7.17.2",
"@mantine/hooks": "^7.17.2",
"@mantine/notifications": "^7.17.2",
"@prisma/client": "^6.5.0",
"@tabler/icons-react": "^3.31.0",
"@tanstack/react-query": "^5.69.0",
"next": "15.2.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"zod": "^3.24.2"
},
"devDependencies": {
"@eslint/eslintrc": "^3",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.2.3",
"eslint-config-prettier": "^10.1.1",
"postcss": "^8.5.3",
"postcss-preset-mantine": "^1.17.0",
"postcss-simple-vars": "^7.0.1",
"prettier": "3.5.3",
"prisma": "^6.5.0",
"typescript": "^5"
}