1import { NextRequest, NextResponse } from 'next/server';
2import { fieldpineServerApi } from '@/lib/server/fieldpineApi';
3import { getStoredAuth } from '@/lib/server/auth';
6 * OpenAPI Barcodes Endpoint
7 * GET /api/v1/openapi/barcodes?scan=9384848284
8 * Decodes barcodes and returns product/item information
10export async function GET(request: NextRequest) {
12 const authData = await getStoredAuth();
13 if (!authData || !authData.authenticated) {
14 return NextResponse.json(
15 { error: 'Authentication required' },
20 const { searchParams } = new URL(request.url);
21 const params: Record<string, string> = {};
23 const scan = searchParams.get('scan');
25 return NextResponse.json(
26 { error: 'scan parameter required' },
32 const geo = searchParams.get('geo');
33 if (geo) params.geo = geo;
35 const barcode = await fieldpineServerApi.apiCall("/Barcodes", {
37 cookie: authData.apiKey,
41 return NextResponse.json({
48 console.error('Barcodes API error:', error);
49 return NextResponse.json(
50 { error: 'Failed to decode barcode' },