ketannnn commited on
Commit
0b18f5a
·
1 Parent(s): 6ca6336

feat: add system reset page and centralize API utility functions

Browse files
frontend/src/app/reset/page.tsx CHANGED
@@ -25,7 +25,7 @@ export default function ResetPage() {
25
  setResult(null);
26
 
27
  try {
28
- const baseUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000";
29
  const resp = await fetch(`${baseUrl}/api/admin/reset-db?password=${encodeURIComponent(password)}`, {
30
  method: "POST",
31
  });
 
25
  setResult(null);
26
 
27
  try {
28
+ const baseUrl = process.env.NEXT_PUBLIC_API_URL || "";
29
  const resp = await fetch(`${baseUrl}/api/admin/reset-db?password=${encodeURIComponent(password)}`, {
30
  method: "POST",
31
  });
frontend/src/lib/api.ts CHANGED
@@ -1,6 +1,6 @@
1
  const API_BASE = typeof process.env.NEXT_PUBLIC_API_URL === "string"
2
  ? process.env.NEXT_PUBLIC_API_URL
3
- : "http://localhost:8000";
4
 
5
  async function request<T>(path: string, options?: RequestInit): Promise<T> {
6
  const url = path.startsWith("http") ? path : `${API_BASE}${path}`;
 
1
  const API_BASE = typeof process.env.NEXT_PUBLIC_API_URL === "string"
2
  ? process.env.NEXT_PUBLIC_API_URL
3
+ : ""; // Fallback to relative paths for single-origin deployments (HF/Nginx)
4
 
5
  async function request<T>(path: string, options?: RequestInit): Promise<T> {
6
  const url = path.startsWith("http") ? path : `${API_BASE}${path}`;