Next.js Discord

Discord Forum

I cannot create dynamic route - no matter what I do it's always being cached

Unanswered
Chien Français Blanc et Orange posted this in #help-forum
Open in Discord
Chien Français Blanc et OrangeOP
Hello, I have a problem with app directory and dynamic routes, I made a cart logic using saleor api, and I try to download my cart on page enter
const getCheckout = async (checkoutId: string) => {
    if (!checkoutId) redirect('/')
    const checkout = await saleor.Checkout({ id: checkoutId })
    if (!checkout.checkout) redirect('/')
    return checkout.checkout
}

const SummaryPage: ServerPage = async () => {
    const checkoutId = cookies().get('dziarsko-cart-id')?.value.toString()
  ....
}

everything ok on initial load, but when for example: user adds a product he's being redirected to /cart page and the product shows up, but when he goes back and adds another product it doesn't show up until he refreshes the page

I think I tried everything:
- setting dynamic to 0
- setting cache: 'no-cache' and no-store
- adding revalidatePath('/cart') on top of my page
- moving cookies() to the page instead of function
- using empty searchParams

and nothing works, any advices? Am I forced to rewrite cart and other related pages to client components?

0 Replies