diff --git a/apps/client/src/lib/trpc.ts b/apps/client/src/lib/trpc.ts index 0b8e077..7733109 100644 --- a/apps/client/src/lib/trpc.ts +++ b/apps/client/src/lib/trpc.ts @@ -11,14 +11,11 @@ export const trpc: CreateTRPCReact = /** * 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 = + (typeof globalThis.process !== "undefined" && + globalThis.process.env?.VITE_TRPC_URL) || + import.meta.env.VITE_TRPC_URL || + "http://localhost:3001/api"; /** * Create tRPC client @@ -26,7 +23,7 @@ function getBaseUrl() { export const trpcClient: TRPCClient = trpc.createClient({ links: [ httpBatchLink({ - url: `${getBaseUrl()}/trpc`, + url: `${BASE_URL}/trpc`, // Optional: add headers, credentials, etc. // headers() { // return { diff --git a/apps/server/package.json b/apps/server/package.json index 2291ebf..8676f51 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -10,7 +10,7 @@ }, "scripts": { "dev": "tsx watch index.ts", - "build": "npx esbuild index.ts --bundle --outfile=dist/index.js --format=esm --platform=node --packages=external", + "build": "pnpm exec esbuild index.ts --bundle --outfile=dist/index.js --format=esm --platform=node --packages=external", "start": "node dist/index.js" }, "dependencies": { @@ -25,6 +25,7 @@ "@types/express": "^5.0.6", "@types/node": "^24.10.1", "concurrently": "^9.2.1", + "esbuild": "^0.27.2", "tsx": "^4.21.0", "typescript": "~5.9.3" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1456c45..597056a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -166,6 +166,9 @@ importers: concurrently: specifier: ^9.2.1 version: 9.2.1 + esbuild: + specifier: ^0.27.2 + version: 0.27.2 tsx: specifier: ^4.21.0 version: 4.21.0 diff --git a/taylordb.yml b/taylordb.yml index ab3a199..4b6d660 100644 --- a/taylordb.yml +++ b/taylordb.yml @@ -24,6 +24,26 @@ services: TAYLORDB_API_TOKEN: secrets.TAYLORDB_API_TOKEN TAYLORDB_SERVER_ID: vars.TAYLORDB_SERVER_ID FRONTEND_URL: routing.client.url + + start: + command: pnpm start --port 3000 + port: 3000 + env: + vars: + TAYLORDB_BASE_URL: vars.TAYLORDB_INTERNAL_BASE_URL + TAYLORDB_API_TOKEN: secrets.TAYLORDB_API_TOKEN + TAYLORDB_SERVER_ID: vars.TAYLORDB_SERVER_ID + FRONTEND_URL: routing.client.url + + build: + commands: + - pnpm build + env: + vars: + TAYLORDB_BASE_URL: vars.TAYLORDB_INTERNAL_BASE_URL + TAYLORDB_API_TOKEN: secrets.TAYLORDB_API_TOKEN + TAYLORDB_SERVER_ID: vars.TAYLORDB_SERVER_ID + FRONTEND_URL: routing.client.url client: workDir: apps/client @@ -36,6 +56,19 @@ services: env: vars: VITE_TRPC_URL: routing.server.url + start: + command: pnpm preview --port 5173 + port: 5173 + env: + vars: + VITE_TRPC_URL: routing.server.url + + build: + commands: + - pnpm build + env: + vars: + VITE_TRPC_URL: routing.server.url taylordb: types: