Route Handlers can be nested anywhere inside the app directory, with similar [slug]/ for dynamic routes. But must only be route.js or page.js at each level.
Next.js browser Web and APIs with and
app/api/route.ts
export const dynamic = 'force-static' //cache get
export async function GET() {
const res = await fetch('https://data.mongodb-api.com/...', {
headers: {
'Content-Type': 'application/json',
'API-Key': process.env.DATA_API_KEY,
},
})
const data = await res.json()
return Response.json({ data })
}