Added env check

This commit is contained in:
sianida26 2024-05-08 00:46:16 +07:00
parent 0d42f6ac24
commit c5024d7b69

View File

@ -1,7 +1,11 @@
import { hc } from "hono/client"; import { hc } from "hono/client";
import { AppType } from "backend"; import { AppType } from "backend";
const client = hc<AppType>("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<AppType>(backendUrl, {
headers: { headers: {
Authorization: `Bearer ${localStorage.getItem("accessToken")}`, Authorization: `Bearer ${localStorage.getItem("accessToken")}`,
}, },