File size: 931 Bytes
ac4a6d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// API Helper and URL configuration
export const API_BASE_URL = import.meta.env.VITE_API_URL !== undefined 
  ? import.meta.env.VITE_API_URL 
  : (import.meta.env.PROD ? "" : "http://localhost:8000");

export const endpoints = {
  redactText: `${API_BASE_URL}/redact`,
  redactFile: `${API_BASE_URL}/redact-pdf/`,
  login: `${API_BASE_URL}/login`,
  register: `${API_BASE_URL}/submit-form`,
  users: `${API_BASE_URL}/users`,
  feedback: `${API_BASE_URL}/feedback`,
  triggerRetrain: `${API_BASE_URL}/retrain`,
  history: `${API_BASE_URL}/history`,
  health: `${API_BASE_URL}/health`,
  metrics: `${API_BASE_URL}/metrics`,
};

export const getAuthHeaders = (customHeaders: Record<string, string> = {}): Record<string, string> => {
  const token = localStorage.getItem("token");
  const headers: Record<string, string> = { ...customHeaders };
  if (token) {
    headers["Authorization"] = `Bearer ${token}`;
  }
  return headers;
};