1

I would like to know what is the best way to revalidate on-demand specific static pages from my server side (express), in my case it's after having created/updated/deleted a category.

I know that according to Next documentation I have to create a file : client/pages/api/revalidate.js that will handle it. But have I to call it from my express server-side (categoryController.js) :

  try {
    await axios.get(
      `http://localhost:3000/api/revalidate?secret=${process.env.REVALIDATE_TOKEN}`
    );
    console.log("successfully revalidated");
    res.status(200).json();
  } catch (error) {
    throw error;
  }

Or is there another proper way to do that ? Thank you for your help !

juliomalves
  • 42,130
  • 20
  • 150
  • 146
Loutag
  • 21
  • 1
  • 6
  • You have to call the API route you created in the Next.js app to handle the revalidation. There's no other way currently. – juliomalves Sep 20 '22 at 19:25
  • Thank you, I'm going to turn it into production mode and check if things are still working – Loutag Sep 20 '22 at 20:03

0 Answers0