From 99a655d0d6aa5446bacc923ac9fea79d1cc9d347 Mon Sep 17 00:00:00 2001 From: Burhanuddin Khatri <144617735+BurhanCantCode@users.noreply.github.com> Date: Sat, 3 Aug 2024 21:00:25 +0500 Subject: [PATCH] Update scanProduct.ts --- pages/api/scanProduct.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) 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 +}