diff --git a/app/[locale]/(main)/layout.tsx b/app/[locale]/(main)/layout.tsx index 4a1c101..82a15af 100644 --- a/app/[locale]/(main)/layout.tsx +++ b/app/[locale]/(main)/layout.tsx @@ -2,6 +2,7 @@ import Footer from "@/app/[locale]/(main)/footer"; import Header from "@/app/[locale]/(main)/header"; import { auth } from "@/auth"; import { SignIn } from "@/components/sign-in"; +import getEnv from "@/lib/env-entry"; import React from "react"; type DashboardProps = { @@ -9,7 +10,7 @@ type DashboardProps = { }; export default async function MainLayout({ children }: DashboardProps) { const session = await auth() - if (!session) return + if (!session && getEnv("SITE_PASSWORD")) return return (
diff --git a/app/api/detail/route.ts b/app/api/detail/route.ts index a9dcdd3..7903e2d 100644 --- a/app/api/detail/route.ts +++ b/app/api/detail/route.ts @@ -2,6 +2,7 @@ import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; import { GetServerDetail } from "@/lib/serverFetch"; import { NextResponse } from "next/server"; import { auth } from "@/auth" +import getEnv from "@/lib/env-entry"; export const runtime = 'edge'; @@ -14,7 +15,7 @@ interface NezhaDataResponse { export const GET = auth(async function GET(req) { - if (!req.auth) { + 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 e562fa2..13a8099 100644 --- a/app/api/monitor/route.ts +++ b/app/api/monitor/route.ts @@ -1,5 +1,6 @@ import { ServerMonitorChart } from "@/app/[locale]/types/nezha-api"; import { auth } from "@/auth"; +import getEnv from "@/lib/env-entry"; import { GetServerMonitor } from "@/lib/serverFetch"; import { NextResponse } from "next/server"; @@ -14,11 +15,10 @@ interface NezhaDataResponse { export const GET = auth(async function GET(req) { - if (!req.auth) { + if (!req.auth && getEnv("SITE_PASSWORD")) { return NextResponse.json({ message: "Not authenticated" }, { status: 401 }); } - const { searchParams } = new URL(req.url); const server_id = searchParams.get("server_id"); if (!server_id) { diff --git a/app/api/server/route.ts b/app/api/server/route.ts index c855878..1a4bfb6 100644 --- a/app/api/server/route.ts +++ b/app/api/server/route.ts @@ -1,5 +1,6 @@ import { ServerApi } from "@/app/[locale]/types/nezha-api"; import { auth } from "@/auth"; +import getEnv from "@/lib/env-entry"; import { GetNezhaData } from "@/lib/serverFetch"; import { NextResponse } from "next/server"; @@ -14,7 +15,7 @@ interface NezhaDataResponse { export const GET = auth(async function GET(req) { - if (!req.auth) { + if (!req.auth && getEnv("SITE_PASSWORD")) { return NextResponse.json({ message: "Not authenticated" }, { status: 401 }); }