diff --git a/src/actions/base.ts b/src/actions/base.ts index 04d7336..eb7b0e2 100644 --- a/src/actions/base.ts +++ b/src/actions/base.ts @@ -1,6 +1,7 @@ 'use server' import {API_BASE_URL, ApiResponse, CLIENT_ID, CLIENT_SECRET} from '@/lib/api' import {add, isBefore} from 'date-fns' +import {isRedirectError} from 'next/dist/client/components/redirect-error' import {cookies, headers} from 'next/headers' import {redirect} from 'next/navigation' import {cache} from 'react' @@ -169,6 +170,9 @@ async function call(url: string, body: RequestInit['body'], auth? } catch (e) { console.error('后端请求失败', url, (e as Error).message) + if (isRedirectError(e)) { + throw e + } throw new Error(`请求失败,网络错误`) } }