From 63555f8fcfd74b5a15ab5ed53ab9fb9fa976d37a Mon Sep 17 00:00:00 2001 From: Eva Raymond Date: Sun, 28 Jul 2024 21:35:29 +0100 Subject: [PATCH] fix:hng-test route; use process.env to avoid t3-oss zod validation --- src/app/(landing-routes)/hng-test/page.tsx | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/app/(landing-routes)/hng-test/page.tsx b/src/app/(landing-routes)/hng-test/page.tsx index c24c2773b..b8262326f 100644 --- a/src/app/(landing-routes)/hng-test/page.tsx +++ b/src/app/(landing-routes)/hng-test/page.tsx @@ -1,17 +1,24 @@ -import { env } from "~/env"; - export default async function HNGTEST() { - const response = await fetch(`${env.NEXT_PUBLIC_BACKEND_PROBE_URL}`, { - cache: "no-store", - }); - const result = response.ok ? await response.json() : {}; - + let result = {} as { message?: string }; + try { + if (process.env.NEXT_PUBLIC_BACKEND_PROBE_URL) { + const response = await fetch( + `${process.env.NEXT_PUBLIC_BACKEND_PROBE_URL}`, + { + cache: "no-store", + }, + ); + result = response.ok ? await response.json() : {}; + } + } catch { + result = {}; + } return (

HNG TEST BACKEND

Version 0.12

-

{env.NEXT_PUBLIC_BACKEND_PROBE_URL}

+

{process.env.NEXT_PUBLIC_BACKEND_PROBE_URL || ""}

{result?.message}