Fixed BASE_URL for build

This commit is contained in:
Umar Adilov 2026-01-17 16:38:23 +05:00
parent 0d74f211a9
commit f7419462f1

View File

@ -11,14 +11,7 @@ export const trpc: CreateTRPCReact<AppRouter, unknown> =
/**
* Get the base URL for tRPC requests
*/
function getBaseUrl() {
if (typeof window !== "undefined") {
// Browser: use relative URL or environment variable
return import.meta.env.VITE_TRPC_URL || "http://localhost:3001/api";
}
// SSR: assume localhost
return "http://localhost:3001/api";
}
const BASE_URL = import.meta.env.VITE_TRPC_URL || "http://localhost:3001/api";
/**
* Create tRPC client
@ -26,7 +19,7 @@ function getBaseUrl() {
export const trpcClient: TRPCClient<AppRouter> = trpc.createClient({
links: [
httpBatchLink({
url: `${getBaseUrl()}/trpc`,
url: `${BASE_URL}/trpc`,
// Optional: add headers, credentials, etc.
// headers() {
// return {