mirror of
https://github.com/woodchen-ink/proxy-go.git
synced 2025-07-18 08:31:55 +08:00
refactor(web): Update API routes to use /admin prefix
- Modify fetch API calls in dashboard, login, and config pages - Update routes to consistently use /admin/api/ endpoint - Ensure uniform API route handling across frontend components
This commit is contained in:
parent
f758db3531
commit
b5a6928a3a
@ -25,7 +25,7 @@ export default function ConfigPage() {
|
||||
return
|
||||
}
|
||||
|
||||
const response = await fetch("/api/config/get", {
|
||||
const response = await fetch("/admin/api/config/get", {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Content-Type': 'application/json'
|
||||
@ -68,7 +68,7 @@ export default function ConfigPage() {
|
||||
return
|
||||
}
|
||||
|
||||
const response = await fetch("/api/config/save", {
|
||||
const response = await fetch("/admin/api/config/save", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
@ -46,7 +46,7 @@ export default function DashboardLayout({
|
||||
}
|
||||
|
||||
// 验证 token 有效性
|
||||
fetch("/api/check-auth").catch(() => {
|
||||
fetch("/admin/api/check-auth").catch(() => {
|
||||
localStorage.removeItem("token")
|
||||
router.push("/login")
|
||||
})
|
||||
|
@ -47,7 +47,7 @@ export default function DashboardPage() {
|
||||
return
|
||||
}
|
||||
|
||||
const response = await fetch("/api/metrics", {
|
||||
const response = await fetch("/admin/api/metrics", {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ export default function LoginPage() {
|
||||
setLoading(true)
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/auth", {
|
||||
const response = await fetch("/admin/api/auth", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
@ -34,7 +34,7 @@ export default function LoginPage() {
|
||||
localStorage.setItem("token", data.token)
|
||||
|
||||
// 验证token
|
||||
const verifyResponse = await fetch("/api/check-auth", {
|
||||
const verifyResponse = await fetch("/admin/api/check-auth", {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${data.token}`,
|
||||
},
|
||||
|
@ -12,7 +12,7 @@ export function Nav() {
|
||||
|
||||
const handleLogout = async () => {
|
||||
try {
|
||||
const response = await fetch("/api/logout", {
|
||||
const response = await fetch("/admin/api/logout", {
|
||||
method: "POST",
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user