Skip to content

Commit b2fb46f

Browse files
committed
feat: use PUBLIC_API_URL as api base url in production
1 parent 4eeb247 commit b2fb46f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/web/src/lib/api.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { edenTreaty } from "@elysiajs/eden";
22
import type { App } from "@packages/server";
33

4-
export const api = edenTreaty<App>(window.location.origin, {}).api;
4+
// In production, PUBLIC_API_URL should be set to the backend URL.
5+
// In development, falls back to window.location.origin and use Vite's proxy to forward API requests to the backend.
6+
const baseUrl = import.meta.env.PUBLIC_API_URL ?? window.location.origin;
7+
8+
export const api = edenTreaty<App>(baseUrl, {}).api;

0 commit comments

Comments
 (0)