import { getAuth } from '../utils/auth'
import { toWebRequest } from 'h3'

export default defineEventHandler(async (event) => {
  const request = toWebRequest(event)

  // Let Better Auth fully handle the request/response (including error pages)
  return await getAuth().handler(request)
})
