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
20ed4a819f
commit
b7e403756a
@ -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 <SignIn />
|
||||
if (!session && getEnv("SITE_PASSWORD")) return <SignIn />
|
||||
|
||||
return (
|
||||
<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 { NextResponse } from "next/server";
|
||||
import { auth } from "@/auth"
|
||||
import getEnv from "@/lib/env-entry";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@ -12,7 +13,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 });
|
||||
}
|
||||
|
||||
|
@ -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";
|
||||
|
||||
@ -12,11 +13,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) {
|
||||
|
@ -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";
|
||||
|
||||
@ -12,7 +13,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 });
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user