mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
fix: empty SITE_PASSWORD
This commit is contained in:
parent
1533b826fb
commit
b2efd54d8a
@ -2,6 +2,7 @@ import Footer from "@/app/[locale]/(main)/footer";
|
|||||||
import Header from "@/app/[locale]/(main)/header";
|
import Header from "@/app/[locale]/(main)/header";
|
||||||
import { auth } from "@/auth";
|
import { auth } from "@/auth";
|
||||||
import { SignIn } from "@/components/sign-in";
|
import { SignIn } from "@/components/sign-in";
|
||||||
|
import getEnv from "@/lib/env-entry";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
type DashboardProps = {
|
type DashboardProps = {
|
||||||
@ -9,7 +10,7 @@ type DashboardProps = {
|
|||||||
};
|
};
|
||||||
export default async function MainLayout({ children }: DashboardProps) {
|
export default async function MainLayout({ children }: DashboardProps) {
|
||||||
const session = await auth()
|
const session = await auth()
|
||||||
if (!session) return <SignIn />
|
if (!session && getEnv("SITE_PASSWORD")) return <SignIn />
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen w-full flex-col">
|
<div className="flex min-h-screen w-full flex-col">
|
||||||
|
@ -2,6 +2,7 @@ import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api";
|
|||||||
import { GetServerDetail } from "@/lib/serverFetch";
|
import { GetServerDetail } from "@/lib/serverFetch";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { auth } from "@/auth"
|
import { auth } from "@/auth"
|
||||||
|
import getEnv from "@/lib/env-entry";
|
||||||
|
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ interface NezhaDataResponse {
|
|||||||
|
|
||||||
export const GET = auth(async function GET(req) {
|
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 });
|
return NextResponse.json({ message: "Not authenticated" }, { status: 401 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { ServerMonitorChart } from "@/app/[locale]/types/nezha-api";
|
import { ServerMonitorChart } from "@/app/[locale]/types/nezha-api";
|
||||||
import { auth } from "@/auth";
|
import { auth } from "@/auth";
|
||||||
|
import getEnv from "@/lib/env-entry";
|
||||||
import { GetServerMonitor } from "@/lib/serverFetch";
|
import { GetServerMonitor } from "@/lib/serverFetch";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
@ -14,11 +15,10 @@ interface NezhaDataResponse {
|
|||||||
|
|
||||||
export const GET = auth(async function GET(req) {
|
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 });
|
return NextResponse.json({ message: "Not authenticated" }, { status: 401 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const { searchParams } = new URL(req.url);
|
const { searchParams } = new URL(req.url);
|
||||||
const server_id = searchParams.get("server_id");
|
const server_id = searchParams.get("server_id");
|
||||||
if (!server_id) {
|
if (!server_id) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { ServerApi } from "@/app/[locale]/types/nezha-api";
|
import { ServerApi } from "@/app/[locale]/types/nezha-api";
|
||||||
import { auth } from "@/auth";
|
import { auth } from "@/auth";
|
||||||
|
import getEnv from "@/lib/env-entry";
|
||||||
import { GetNezhaData } from "@/lib/serverFetch";
|
import { GetNezhaData } from "@/lib/serverFetch";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ interface NezhaDataResponse {
|
|||||||
|
|
||||||
export const GET = auth(async function GET(req) {
|
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 });
|
return NextResponse.json({ message: "Not authenticated" }, { status: 401 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user