oh oops
This commit is contained in:
@@ -1,23 +1,20 @@
|
|||||||
import {
|
import { createTRPCProxyClient, httpBatchLink, loggerLink } from "@trpc/client";
|
||||||
createTRPCProxyClient,
|
import { env } from "~/env/server";
|
||||||
httpBatchLink,
|
|
||||||
loggerLink,
|
|
||||||
} from '@trpc/client';
|
|
||||||
import { AppRouter } from "~/server/api/root";
|
import { AppRouter } from "~/server/api/root";
|
||||||
|
|
||||||
const getBaseUrl = () => {
|
const getBaseUrl = () => {
|
||||||
if (typeof window !== "undefined") return "";
|
if (typeof window !== "undefined") return "";
|
||||||
// replace example.com with your actual production url
|
// replace example.com with your actual production url
|
||||||
if (process.env.NODE_ENV === "production") return "https://example.com";
|
if (process.env.NODE_ENV === "production") return env.VITE_DOMAIN;
|
||||||
return `http://localhost:${process.env.PORT ?? 3000}`;
|
return `http://localhost:${process.env.PORT ?? 3000}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// create the client, export it
|
// create the client, export it
|
||||||
export const api = createTRPCProxyClient<AppRouter>({
|
export const api = createTRPCProxyClient<AppRouter>({
|
||||||
links: [
|
links: [
|
||||||
// will print out helpful logs when using client
|
// will print out helpful logs when using client
|
||||||
loggerLink(),
|
loggerLink(),
|
||||||
// identifies what url will handle trpc requests
|
// identifies what url will handle trpc requests
|
||||||
httpBatchLink({ url: `${getBaseUrl()}/api/trpc` })
|
httpBatchLink({ url: `${getBaseUrl()}/api/trpc` })
|
||||||
],
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user