#DB query not updating with NextJS and Vercel

33 messages · Page 1 of 1 (latest)

junior cove
#

I have a NextJS app connected with Supabase up and running and on localhost I am able to change data in DB and see changes reflected (with hard refresh).

I also have the same app deployed on Vercel and changes to DB are not reflected there even with hard refresh.

I tried reading about caching on Vercel and I wasn't able to really understand too much.

Does anyone know how I may be able to fix this?

Here is my code which is fetching data in question:

import { supabase } from "../lib/supabaseClient";

export default async function Home() {
  // Fetch data from Supabase in a server-side function
  const { data: users, error } = await supabase.from("users").select("*");

  if (error) {
    console.error("Error fetching users:", error);
    return (
      <div>
        <h1>Error Fetching Users</h1>
        <p>{error.message}</p>
      </div>
    );
  }

  return (
    <div>
      <h1>Users List</h1>
      {users && users.length > 0 ? (
        <ul>
          {users.map((user) => (
            <li key={user.id}>{user.name}</li>
          ))}
        </ul>
      ) : (
        <p>No users found</p>
      )}
    </div>
  );
}
civic lichenBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

crisp bear
#

can u show me the output of next build

junior cove
#

sure, one sec

#

do you mean the build logs?

crisp bear
#

yup

junior cove
crisp bear
#

this will cause next to rerender rsc components on request

#

for that route

junior cove
crisp bear
#

👍

junior cove
crisp bear
#

check this

#

i noticed u are using deprecated libraries

#

follow this guide and after u are done remove "use client" directive from your layout.tsx

junior cove
#

thanks

#

sorry, was on phone for a bit

#

deprecated libs.. I guess that's one hazard of asking chatgpt for instructions

#

thanks for pointing out.. will work to resolve that also

junior cove
#

well, I followed that guide but now I have a new problem.. a cookie is being created on sign in but I don't see any example code anywhere showing how to handle that cookie in my nextjs code in order to evaluate if session exists, get data from session etc

#

so.. I could still push what I have so far just to test if it somehow alleviates the original issue regarding stale data

#

come to think of it

junior cove
#

@crisp bear I rewrote all the auth stuff using the guide that you pointed me to and changes to DB are also being reflected on deployed version now

#

thanks

crisp bear
#

make sure to mark my answer as solution

junior cove
#

sure.. how do I do that exactly?

crisp bear