From 4e8de3658f4d6304d6bf2781cf04da9149c716d5 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 19 Mar 2026 12:58:21 +0100 Subject: [PATCH] fix(api): use API_INTERNAL_URL in tags and persons proxy routes Both SvelteKit API proxy routes were hardcoding http://localhost:8080, breaking typeahead search in Docker environments. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/routes/api/persons/+server.ts | 3 ++- frontend/src/routes/api/tags/+server.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/routes/api/persons/+server.ts b/frontend/src/routes/api/persons/+server.ts index 71f51963..23ee59ae 100644 --- a/frontend/src/routes/api/persons/+server.ts +++ b/frontend/src/routes/api/persons/+server.ts @@ -1,5 +1,6 @@ import { json } from '@sveltejs/kit'; import type { RequestHandler } from './$types'; +import { env } from 'process'; export const GET: RequestHandler = async ({ url, fetch }) => { // 1. Suchparameter aus der URL des Browsers holen @@ -8,7 +9,7 @@ export const GET: RequestHandler = async ({ url, fetch }) => { try { // 3. Anfrage an das Java-Backend weiterleiten (Server-to-Server) // Wir nutzen hier den internen Docker-Hostnamen oder localhost, je nach Netzwerk - const backendUrl = `http://localhost:8080/api/persons?q=${encodeURIComponent(q)}`; + const backendUrl = `${env.API_INTERNAL_URL || 'http://localhost:8080'}/api/persons?q=${encodeURIComponent(q)}`; const response = await fetch(backendUrl, { method: 'GET', diff --git a/frontend/src/routes/api/tags/+server.ts b/frontend/src/routes/api/tags/+server.ts index 63c9829d..4e43e11b 100644 --- a/frontend/src/routes/api/tags/+server.ts +++ b/frontend/src/routes/api/tags/+server.ts @@ -1,5 +1,6 @@ import { json } from '@sveltejs/kit'; import type { RequestHandler } from './$types'; +import { env } from 'process'; export const GET: RequestHandler = async ({ url, fetch }) => { // 1. Suchparameter aus der URL des Browsers holen @@ -8,7 +9,7 @@ export const GET: RequestHandler = async ({ url, fetch }) => { try { // 3. Anfrage an das Java-Backend weiterleiten (Server-to-Server) // Wir nutzen hier den internen Docker-Hostnamen oder localhost, je nach Netzwerk - const backendUrl = `http://localhost:8080/api/tags?q=${encodeURIComponent(q)}`; + const backendUrl = `${env.API_INTERNAL_URL || 'http://localhost:8080'}/api/tags?q=${encodeURIComponent(q)}`; const response = await fetch(backendUrl, { method: 'GET',