mirror of
https://github.com/supabase/supabase.git
synced 2026-07-03 00:24:25 +08:00
The Vercel Data Cache caches data across deployments, and we want to check for updates in federated content, so let's revalidate the data once a day. It may be more efficient to revalidate on-demand, since we don't change most of these sources once a day, but that requires setting up an API endpoint (and figuring out how to authenticate it), so this is quick-and-easy for now.
18 lines
564 B
TypeScript
18 lines
564 B
TypeScript
/**
|
|
* Next.js extends native `fetch` with revalidation options.
|
|
*
|
|
* This module provides some reusable utility functions to set revalidation
|
|
* options for `fetch`, for example when it needs to be passed to a
|
|
* third-party API.
|
|
*/
|
|
|
|
import { ONE_DAY_IN_SECONDS } from './helpers.time'
|
|
|
|
function fetchWithNextOptions(options: NextFetchRequestConfig) {
|
|
return (info: RequestInfo) => fetch(info, { next: options })
|
|
}
|
|
|
|
const fetchRevalidatePerDay = fetchWithNextOptions({ revalidate: ONE_DAY_IN_SECONDS })
|
|
|
|
export { fetchWithNextOptions, fetchRevalidatePerDay }
|