Spaces:
Build error
Build error
Download src/lib/api-client.ts from GodRad/Rag_SaaS_Admin_UI_V4: direct link, hf CLI and curl.
- Browser
- Download file 955 Bytes
-
https://huggingface.co/spaces/GodRad/Rag_SaaS_Admin_UI_V4/resolve/main/src/lib/api-client.ts
- Command line
-
hf download hf://spaces/GodRad/Rag_SaaS_Admin_UI_V4/src/lib/api-client.ts
-
curl -L -o api-client.ts https://huggingface.co/spaces/GodRad/Rag_SaaS_Admin_UI_V4/resolve/main/src/lib/api-client.ts
955 Bytes
| /// <reference types="vite/client" /> | |
| import axios from "axios" | |
| const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || "http://localhost:7860" | |
| console.log("Using API Base URL (Admin):", API_BASE_URL); | |
| const adminClient = axios.create({ | |
| baseURL: API_BASE_URL, | |
| headers: { | |
| "Content-Type": "application/json", | |
| }, | |
| }) | |
| adminClient.interceptors.request.use((config) => { | |
| const admin_token = localStorage.getItem("admin_token") | |
| if (admin_token) { | |
| config.headers.Authorization = `Bearer ${admin_token}` | |
| } | |
| return config | |
| }) | |
| adminClient.interceptors.response.use( | |
| (response) => response, | |
| (error) => { | |
| if (error.response?.status === 401 && !error.config.url?.includes('/admin/auth/')) { | |
| localStorage.removeItem("admin_token") | |
| window.location.href = "/login" | |
| } | |
| return Promise.reject(error) | |
| } | |
| ) | |
| export default adminClient | |