Files
JJ KasperandGitHub ce746ef5c2 Handle unstable_cache in pages (#49624)
Ensures this method works in pages the same as in app as discussed. 

x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1683242040712889)
x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1683724596461329)
2023-05-10 13:59:48 -07:00

26 lines
417 B
JavaScript

import { unstable_cache } from 'next/cache'
export const config = {
runtime: 'edge',
}
export default async function handler(req) {
const data = await unstable_cache(async () => {
return {
random: Math.random(),
}
})()
return new Response(
JSON.stringify({
now: Date.now(),
data,
}),
{
headers: {
'content-type': 'application/json',
},
}
)
}