mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
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)
26 lines
417 B
JavaScript
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',
|
|
},
|
|
}
|
|
)
|
|
}
|