Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

846 B
Raw Blame
import * as Sentry from '@sentry/nextjs'
import { type NextRequest } from 'next/server'

import { corsHeaders } from '../cors'
import { _handleFtsSearchRequest } from './route.utils'

export const runtime = 'edge'

export async function OPTIONS() {
  return new Response(null, { headers: corsHeaders })
}

export async function POST(request: NextRequest) {
  try {
    const response = await _handleFtsSearchRequest(request)
    Object.entries(corsHeaders).forEach(([key, value]) => response.headers.set(key, value))
    return response
  } catch (error) {
    console.error('Error handling docs full-text search request:', error)
    Sentry.captureException(error, { tags: { route: 'search-fts' } })
    return Response.json(
      { error: 'There was an error processing your request' },
      { status: 500, headers: corsHeaders }
    )
  }
}