From 87f28e4da926d28b4140fd691690d007cdd21e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20=C4=B0pek?= Date: Tue, 11 Nov 2025 18:50:33 +0300 Subject: [PATCH] fix: correct SQL parameter index and improve API URL handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed SQL UPDATE query parameter mismatch ($4 → $3) in Homebrew package fetcher - Enhanced API_BASE_URL configuration to handle empty strings and trailing slashes, defaulting to '/api' for relative paths --- src/lib/api/client.ts | 4 +++- src/services/homebrewPackageFetcher.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/api/client.ts b/src/lib/api/client.ts index 17a097d..3f9401f 100644 --- a/src/lib/api/client.ts +++ b/src/lib/api/client.ts @@ -1,6 +1,8 @@ import { Platform, Package, FilterOptions } from '@/types' -const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3002/api' +const API_BASE_URL = (process.env.NEXT_PUBLIC_API_URL && process.env.NEXT_PUBLIC_API_URL.trim() !== '') + ? process.env.NEXT_PUBLIC_API_URL.replace(/\/$/, '') + : '/api' class ApiClient { private async request(endpoint: string, options: RequestInit = {}): Promise { diff --git a/src/services/homebrewPackageFetcher.ts b/src/services/homebrewPackageFetcher.ts index 44df17c..f14260e 100644 --- a/src/services/homebrewPackageFetcher.ts +++ b/src/services/homebrewPackageFetcher.ts @@ -153,7 +153,7 @@ export class HomebrewPackageFetcher { await query( `UPDATE packages SET version = $1, description = $2, updated_at = NOW() - WHERE id = $4`, + WHERE id = $3`, [pkg.version, pkg.description, existingResult.rows[0].id] ) updated++