Fixed BASE_URL for build
This commit is contained in:
parent
0d74f211a9
commit
f7419462f1
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user