From 819aea801e4bd3ffe566b6b7ec4539e05c4a4b9d Mon Sep 17 00:00:00 2001 From: Christian Beutel <> Date: Fri, 4 Jul 2025 10:16:11 +0200 Subject: [PATCH] return json errors from valhalla api route --- web/src/routes/api/v1/valhalla/route/+server.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/web/src/routes/api/v1/valhalla/route/+server.ts b/web/src/routes/api/v1/valhalla/route/+server.ts index 60d0f70c..e27a4e48 100644 --- a/web/src/routes/api/v1/valhalla/route/+server.ts +++ b/web/src/routes/api/v1/valhalla/route/+server.ts @@ -5,16 +5,17 @@ import { error, json, type NumericRange, type RequestEvent } from "@sveltejs/kit export async function POST(event: RequestEvent) { const data = await event.request.json() if (!env.PUBLIC_VALHALLA_URL) { - return error(400, "PUBLIC_VALHALLA_URL not set") + return json({ message: "PUBLIC_VALHALLA_URL not set" }, { status: 400 }) } try { - const r = await event.fetch(env.PUBLIC_VALHALLA_URL + '/route', { method: "POST", body: JSON.stringify(data) }); + const r = await event.fetch(env.PUBLIC_VALHALLA_URL + '/route', { method: "POST", body: JSON.stringify(data) }); const response = await r.json(); if (!r.ok) { - throw error(r.status as NumericRange<400,500>, response); + return json({ message: response }, { status: r.status }) + } return json(response); } catch (e: any) { - throw error(e.status || 500, e) + return json({ message: e }, { status: 500 }) } } \ No newline at end of file