Next.js Discord

Discord Forum

LocalHost and Vercel produce different results

Answered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
Need help 😦

I have this home page for my products and it uses prisma to search through my database and return all the products to display.

my issue right now is it correctly fetches and displays all the products when i run it in localhost however when its deployed on vercel, it only fetches and displays products that were present in the database at the time it was deployed. So if i add more products to the db, my deployment never changes.

import Image from "next/image";
import { prisma } from "@/lib/db/prisma";
import ProductCard from "../components/ProductCard";
export default async function Home() {
const products = await prisma.product.findMany({
where: {brand: "pesach to go"},
orderBy: { id: "desc" },
});
return (
<div className="bg-black">
<div className="flex justify-center">
<Image src={"/ptg_logo.jpg"} alt="ptg logo" width={500}height={300} className=""/>
</div>
<div className="my-4 grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3 p-4">
{products.map((product) => (
<ProductCard product={product} key={product.id} />
))}
</div>
</div>
);
}

Any help regarding this issue would be appreciated!
Answered by joulev
add this to your page
export const dynamic = 'force-dynamic'
View full answer

8 Replies

Masai LionOP
to add to this, it looks like if i make changes to the program, then commit my changes and deploy again. The page displays everything currently in the database. But again if i make any changes to the db now, the page remains unchanged
Answer
or
export const revalidate = 0
Masai LionOP
Where? Just at the top? @joulev
at the bottom, at the top – you choose
it's just a segment config option
Masai LionOP
@joulev Bless your soul frfr