From c5024d7b69e03bc82f8b128d908f52286284e86b Mon Sep 17 00:00:00 2001 From: sianida26 Date: Wed, 8 May 2024 00:46:16 +0700 Subject: [PATCH] Added env check --- apps/frontend/src/honoClient.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/frontend/src/honoClient.ts b/apps/frontend/src/honoClient.ts index 7cbd554..f4a8186 100644 --- a/apps/frontend/src/honoClient.ts +++ b/apps/frontend/src/honoClient.ts @@ -1,7 +1,11 @@ import { hc } from "hono/client"; import { AppType } from "backend"; -const client = hc("http://localhost:3000", { +const backendUrl = import.meta.env.VITE_BACKEND_BASE_URL as string | undefined; + +if (!backendUrl) throw new Error("Backend URL not set"); + +const client = hc(backendUrl, { headers: { Authorization: `Bearer ${localStorage.getItem("accessToken")}`, },