mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
Merge branch 'main' into cloudflare
This commit is contained in:
commit
fc5043bf23
@ -3,7 +3,6 @@ import Header from "@/app/[locale]/(main)/header";
|
|||||||
import { auth } from "@/auth";
|
import { auth } from "@/auth";
|
||||||
import { SignIn } from "@/components/SignIn";
|
import { SignIn } from "@/components/SignIn";
|
||||||
import getEnv from "@/lib/env-entry";
|
import getEnv from "@/lib/env-entry";
|
||||||
import { redirect } from "next/navigation";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
type DashboardProps = {
|
type DashboardProps = {
|
||||||
|
@ -2,6 +2,7 @@ import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api";
|
|||||||
import { auth } from "@/auth";
|
import { auth } from "@/auth";
|
||||||
import getEnv from "@/lib/env-entry";
|
import getEnv from "@/lib/env-entry";
|
||||||
import { GetServerDetail } from "@/lib/serverFetch";
|
import { GetServerDetail } from "@/lib/serverFetch";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
@ -15,7 +16,7 @@ interface NezhaDataResponse {
|
|||||||
|
|
||||||
export const GET = auth(async function GET(req) {
|
export const GET = auth(async function GET(req) {
|
||||||
if (!req.auth && getEnv("SitePassword")) {
|
if (!req.auth && getEnv("SitePassword")) {
|
||||||
return NextResponse.json({ message: "Not authenticated" }, { status: 401 });
|
redirect("/api/auth/signin");
|
||||||
}
|
}
|
||||||
|
|
||||||
const { searchParams } = new URL(req.url);
|
const { searchParams } = new URL(req.url);
|
||||||
|
@ -2,6 +2,7 @@ import { ServerMonitorChart } from "@/app/[locale]/types/nezha-api";
|
|||||||
import { auth } from "@/auth";
|
import { auth } from "@/auth";
|
||||||
import getEnv from "@/lib/env-entry";
|
import getEnv from "@/lib/env-entry";
|
||||||
import { GetServerMonitor } from "@/lib/serverFetch";
|
import { GetServerMonitor } from "@/lib/serverFetch";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export const runtime = "edge";
|
export const runtime = "edge";
|
||||||
@ -15,7 +16,7 @@ interface NezhaDataResponse {
|
|||||||
|
|
||||||
export const GET = auth(async function GET(req) {
|
export const GET = auth(async function GET(req) {
|
||||||
if (!req.auth && getEnv("SitePassword")) {
|
if (!req.auth && getEnv("SitePassword")) {
|
||||||
return NextResponse.json({ message: "Not authenticated" }, { status: 401 });
|
redirect("/api/auth/signin");
|
||||||
}
|
}
|
||||||
|
|
||||||
const { searchParams } = new URL(req.url);
|
const { searchParams } = new URL(req.url);
|
||||||
|
@ -2,6 +2,7 @@ import { ServerApi } from "@/app/[locale]/types/nezha-api";
|
|||||||
import { auth } from "@/auth";
|
import { auth } from "@/auth";
|
||||||
import getEnv from "@/lib/env-entry";
|
import getEnv from "@/lib/env-entry";
|
||||||
import { GetNezhaData } from "@/lib/serverFetch";
|
import { GetNezhaData } from "@/lib/serverFetch";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
@ -15,7 +16,7 @@ interface NezhaDataResponse {
|
|||||||
|
|
||||||
export const GET = auth(async function GET(req) {
|
export const GET = auth(async function GET(req) {
|
||||||
if (!req.auth && getEnv("SitePassword")) {
|
if (!req.auth && getEnv("SitePassword")) {
|
||||||
return NextResponse.json({ message: "Not authenticated" }, { status: 401 });
|
redirect("/api/auth/signin");
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = (await GetNezhaData()) as NezhaDataResponse;
|
const response = (await GetNezhaData()) as NezhaDataResponse;
|
||||||
|
Loading…
Reference in New Issue
Block a user