From 6ba8f09d2074cd6d7c64295d8473d15f063b9f0f Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Mon, 21 Oct 2024 02:27:31 +0800 Subject: [PATCH] doc: new env --- README.md | 1 + app/[locale]/(main)/layout.tsx | 2 +- app/api/detail/route.ts | 2 +- app/api/monitor/route.ts | 2 +- app/api/server/route.ts | 2 +- auth.ts | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e20c29e..520714a 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ | ------------------------------ | ------------------------ | ------------------------------------------------------------- | | NezhaBaseUrl | nezha 面板地址 | http://120.x.x.x:8008 | | NezhaAuth | nezha 面板 API Token | 5hAY3QX6Nl9B3Uxxxx26KMvOMyXS1Udi | +| Site_Password | 页面密码 | 123456 | | DefaultLocale | 面板默认显示语言 | **默认**:en [简中:zh 繁中:zh-t 英语:en 日语:ja] | | ForceShowAllServers | 是否强制显示所有服务器 | **默认**:false | | NEXT_PUBLIC_NezhaFetchInterval | 获取数据间隔(毫秒) | **默认**:2000 | diff --git a/app/[locale]/(main)/layout.tsx b/app/[locale]/(main)/layout.tsx index ef107f1..cff6f75 100644 --- a/app/[locale]/(main)/layout.tsx +++ b/app/[locale]/(main)/layout.tsx @@ -12,7 +12,7 @@ type DashboardProps = { export default async function MainLayout({ children }: DashboardProps) { const session = await auth(); - if (!session && getEnv("SITE_PASSWORD")) { + if (!session && getEnv("Site_Password")) { if (getEnv("CF_PAGES")) { redirect("/api/auth/signin"); } else { diff --git a/app/api/detail/route.ts b/app/api/detail/route.ts index 773712b..2cae57b 100644 --- a/app/api/detail/route.ts +++ b/app/api/detail/route.ts @@ -14,7 +14,7 @@ interface NezhaDataResponse { } export const GET = auth(async function GET(req) { - if (!req.auth && getEnv("SITE_PASSWORD")) { + if (!req.auth && getEnv("Site_Password")) { return NextResponse.json({ message: "Not authenticated" }, { status: 401 }); } diff --git a/app/api/monitor/route.ts b/app/api/monitor/route.ts index fc5e8fb..fe34fe5 100644 --- a/app/api/monitor/route.ts +++ b/app/api/monitor/route.ts @@ -14,7 +14,7 @@ interface NezhaDataResponse { } export const GET = auth(async function GET(req) { - if (!req.auth && getEnv("SITE_PASSWORD")) { + if (!req.auth && getEnv("Site_Password")) { return NextResponse.json({ message: "Not authenticated" }, { status: 401 }); } diff --git a/app/api/server/route.ts b/app/api/server/route.ts index 7ae6f81..2ea3851 100644 --- a/app/api/server/route.ts +++ b/app/api/server/route.ts @@ -14,7 +14,7 @@ interface NezhaDataResponse { } export const GET = auth(async function GET(req) { - if (!req.auth && getEnv("SITE_PASSWORD")) { + if (!req.auth && getEnv("Site_Password")) { return NextResponse.json({ message: "Not authenticated" }, { status: 401 }); } diff --git a/auth.ts b/auth.ts index ca98657..419d3ee 100644 --- a/auth.ts +++ b/auth.ts @@ -11,7 +11,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth({ password: {}, }, authorize: async (credentials) => { - if (credentials.password === getEnv("SITE_PASSWORD")) { + if (credentials.password === getEnv("Site_Password")) { return { id: "0" }; } return null;