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
|
* Get the base URL for tRPC requests
|
||||||
*/
|
*/
|
||||||
function getBaseUrl() {
|
const BASE_URL = import.meta.env.VITE_TRPC_URL || "http://localhost:3001/api";
|
||||||
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";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create tRPC client
|
* Create tRPC client
|
||||||
|
|
@ -26,7 +19,7 @@ function getBaseUrl() {
|
||||||
export const trpcClient: TRPCClient<AppRouter> = trpc.createClient({
|
export const trpcClient: TRPCClient<AppRouter> = trpc.createClient({
|
||||||
links: [
|
links: [
|
||||||
httpBatchLink({
|
httpBatchLink({
|
||||||
url: `${getBaseUrl()}/trpc`,
|
url: `${BASE_URL}/trpc`,
|
||||||
// Optional: add headers, credentials, etc.
|
// Optional: add headers, credentials, etc.
|
||||||
// headers() {
|
// headers() {
|
||||||
// return {
|
// return {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user