eduproj2/app/_examples/route-handler/route.ts
Michael Zhang 1711557f4c initial
2023-08-01 18:38:06 -04:00

19 lines
749 B
TypeScript

// TODO: Duplicate or move this file outside the `_examples` folder to make it a route
import { createRouteHandlerClient } from '@supabase/auth-helpers-nextjs'
import { cookies } from 'next/headers'
import { NextResponse } from 'next/server'
export const dynamic = 'force-dynamic'
export async function GET() {
// Create a Supabase client configured to use cookies
const supabase = createRouteHandlerClient({ cookies })
// This assumes you have a `todos` table in Supabase. Check out
// the `Create Table and seed with data` section of the README 👇
// https://github.com/vercel/next.js/blob/canary/examples/with-supabase/README.md
const { data: todos } = await supabase.from('todos').select()
return NextResponse.json(todos)
}