Next.js Discord

Discord Forum

revalidatePath not working as expected for me

Unanswered
Wuchang bream posted this in #help-forum
Open in Discord
Avatar
Wuchang breamOP
as You can see in the video the cache doesn't revalidate when i revisit Time page again.
const Home = () => {
  return (
    <div>
      <Link href="/time" className="border-2 p-2 mx-auto">
        Time
      </Link>
    </div>
  );
};

export default Home;


const Time = async () => {
  const res = await fetch("http://localhost:3000/api");
  const data = res.json();

  return <div>{data}</div>;
};

export default Time;

export const dynamic = "force-dynamic";



import { revalidatePath } from "next/cache";
import { NextResponse } from "next/server";

export const GET = () => {
  revalidatePath("/time");
  return NextResponse.json(Date.now());
};

export const dynamic = "force-dynamic";
Image

0 Replies