import { claimLocateRequest } from '@/lib/db'; import { corsJson, corsPreflight } from '../../cors'; /** The extension takes the oldest pending request. Claiming marks it in-flight so * the next poll doesn't run the same click a second time. */ export async function POST() { const row = claimLocateRequest(); if (!row) return corsJson({ request: null }); return corsJson({ request: { id: row.id, selector: row.selector, index: row.match_index, urlPattern: row.url_pattern, }, }); } export async function OPTIONS() { return corsPreflight(); }