Next.js 13/14 stale data when changing RLS or table data.
在某些情况下,Next.js 会缓存 URL。这导致用户在 RLS 变化的初期花大量时间调试。即使在 UI 中更改表数据,这些情况下也不会返回最新数据。
🌐 Next.js caches URLs in certain cases. This is causing users to lose lots of time debugging early on with RLS changes. Changing the table data in the UI will also not be returned in these cases.
你可以查看 Dashboard API Edge 日志,看看请求是否到达了 Supabase。另一种检查 URL 缓存是否影响你的方法是把 .select('*') 改成 .select('colname') 或者更改列名。这样可以清除 next.js 缓存。
🌐 You can look at the Dashboard API Edge log to see if the request is making it to Supabase.
Another way to check if the URL caching is impacting you is to change .select('*') to .select('colname') or change column names. This would bust the next.js cache.
用户提出了以下三种关闭缓存的选项,但需要的话请参考 next.js 文档。
🌐 Users have suggested the following three options to turn off the caching, but refer to next.js docs as needed.
export const dynamic = 'force-dynamic'; // no caching
或者
export const fetchCache = 'force-no-store' // to page.js
或者
export const revalidate = 0