Next.js Discord

Discord Forum

Error when fetching data during deployment

Unanswered
Sun bear posted this in #help-forum
Open in Discord
Sun bearOP
Hello guys, I hope u are doing well.

I have a little problem with fetching data in deployment on vercel.

When I'm in local, everything works well, the page where I'm fetching all my data works well ( 27 Mo of data ).

But when I deploy it on vercel, I have this error :

11 Replies

Sun bearOP
The page in local ( that works ) looks like this :
this is my back-end code :

import { NextResponse } from "next/server";
import Cars from "@/app/(models)/Carsdetail";

export async function fetchAllCars() {
  try {
    return await Cars.find();
  } catch (err) {
    return NextResponse.json(
      { message: "Failed to get infos about cars", err },
      { status: 500 }
    );
  }
}
and this is my front-End code :
I fetch 27Mo of data because my Images are encoded in base64 and are in my BDD, that's why it makes a lot of data
But I don't know hoow to do it differently, how you guys do to have so many images on your pages ?
Thanks for looking at my problem tho, I hope it will be better haha
Sun bearOP
...
Cape lion
Cape lion
You can implement pagination or infinite scroll to request just a small part of data for the initial load.
Here a link to implement infinite scroll. I have not tested it.
https://medium.com/@ferlat.simon/infinite-scroll-with-nextjs-server-actions-a-simple-guide-76a894824cfd
@Cape lion Hi, Maybe it can help you. https://vercel.com/docs/errors/FALLBACK_BODY_TOO_LARGE
Sun bearOP
Nice I will give a look on this ty bro !