diff --git a/pages/api/scanProduct.ts b/pages/api/scanProduct.ts index 04def52..566dd6f 100644 --- a/pages/api/scanProduct.ts +++ b/pages/api/scanProduct.ts @@ -1,24 +1,14 @@ import type { NextApiRequest, NextApiResponse } from 'next' import { scanProduct } from '../../utils/visionUtils'; -import path from 'path'; export default async function handler(req: NextApiRequest, res: NextApiResponse) { if (req.method === 'POST') { try { - let credentialsPath = process.env.GOOGLE_APPLICATION_CREDENTIALS; - if (credentialsPath) { - credentialsPath = path.resolve(process.cwd(), credentialsPath); - } - const { imageData } = req.body; console.log('Received image data length:', imageData.length); - console.log('Using credentials file:', credentialsPath); const result = await scanProduct(imageData); console.log('Scan result:', result); - res.status(200).json({ - ...result, - allLabels: result.allLabels || [] - }); + res.status(200).json(result); } catch (error) { console.error('Error in scanProduct API:', error); res.status(500).json({ error: 'Failed to scan product' }); @@ -27,4 +17,4 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) res.setHeader('Allow', ['POST']); res.status(405).end(`Method ${req.method} Not Allowed`); } -} \ No newline at end of file +}