diff --git a/src/lib/api.ts b/src/lib/api.ts index 0b0675f..c011799 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -2,19 +2,11 @@ import { createTRPCProxyClient, httpBatchLink, loggerLink } from "@trpc/client"; import { env } from "~/env/server"; import { AppRouter } from "~/server/api/root"; -const getBaseUrl = () => { - if (typeof window !== "undefined") return ""; - // replace example.com with your actual production url - if (process.env.NODE_ENV === "production") return env.VITE_DOMAIN; - return `http://localhost:${process.env.PORT ?? 3000}`; -}; - -// create the client, export it export const api = createTRPCProxyClient({ links: [ // will print out helpful logs when using client loggerLink(), // identifies what url will handle trpc requests - httpBatchLink({ url: `${getBaseUrl()}/api/trpc` }) + httpBatchLink({ url: `${env.VITE_DOMAIN}/api/trpc` }) ] });