Download frontend/src/api/auth.ts from nst1/gemini: direct link, hf CLI and curl.
- Browser
- Download file 723 Bytes
-
https://huggingface.co/spaces/nst1/gemini/resolve/main/frontend/src/api/auth.ts
- Command line
-
hf download hf://spaces/nst1/gemini/frontend/src/api/auth.ts
-
curl -L -o auth.ts https://huggingface.co/spaces/nst1/gemini/resolve/main/frontend/src/api/auth.ts
723 Bytes
| import apiClient from './client' | |
| import type { LoginRequest, LoginResponse } from '@/types/api' | |
| export const authApi = { | |
| login: (data: LoginRequest) => { | |
| const payload = new URLSearchParams() | |
| payload.append('admin_key', data.password) | |
| return apiClient.post<URLSearchParams, LoginResponse>('/login', payload, { | |
| headers: { | |
| 'Content-Type': 'application/x-www-form-urlencoded', | |
| }, | |
| }) | |
| }, | |
| logout: () => | |
| apiClient.post('/logout'), | |
| // 必须调用需要鉴权的接口,不能用 /health(公开接口),否则登出后会被误判为已登录 | |
| checkAuth: () => | |
| apiClient.get('/admin/stats', { | |
| headers: { | |
| 'X-Skip-Auth-Redirect': '1', | |
| }, | |
| }), | |
| } | |