refactor(monorepo): decouple api and webui into workspaces packages

This commit is contained in:
yiling
2026-06-01 23:35:00 +08:00
parent e3f4fa219e
commit 1f341c15d0
288 changed files with 18024 additions and 21178 deletions
+29
View File
@@ -0,0 +1,29 @@
import { hc } from 'hono/client'
import type { AppType } from '@shumai/api'
import { useAuthStore } from '@/ui/stores/auth'
const customFetch = async (input: RequestInfo | URL, init?: RequestInit) => {
const response = await fetch(input, init)
if (response.status === 401) {
const url = input.toString()
// Don't redirect if we are already on login page, it's an auth request, or we are on a public share page
if (
!window.location.pathname.includes('/login') &&
!window.location.pathname.startsWith('/share/') &&
!url.includes('/api/authn')
) {
useAuthStore.getState().clearAuth()
window.location.href = '/login'
}
}
return response
}
export const client = hc<AppType>('/', {
fetch: customFetch,
init: {
credentials: 'include',
},
})