Merge branch 'main' into cloudflare

This commit is contained in:
hamster1963 2024-10-21 10:25:10 +08:00
commit fc5043bf23
4 changed files with 6 additions and 4 deletions

View File

@ -3,7 +3,6 @@ import Header from "@/app/[locale]/(main)/header";
import { auth } from "@/auth";
import { SignIn } from "@/components/SignIn";
import getEnv from "@/lib/env-entry";
import { redirect } from "next/navigation";
import React from "react";
type DashboardProps = {

View File

@ -2,6 +2,7 @@ import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api";
import { auth } from "@/auth";
import getEnv from "@/lib/env-entry";
import { GetServerDetail } from "@/lib/serverFetch";
import { redirect } from "next/navigation";
import { NextResponse } from "next/server";
export const runtime = 'edge';
@ -15,7 +16,7 @@ interface NezhaDataResponse {
export const GET = auth(async function GET(req) {
if (!req.auth && getEnv("SitePassword")) {
return NextResponse.json({ message: "Not authenticated" }, { status: 401 });
redirect("/api/auth/signin");
}
const { searchParams } = new URL(req.url);

View File

@ -2,6 +2,7 @@ import { ServerMonitorChart } from "@/app/[locale]/types/nezha-api";
import { auth } from "@/auth";
import getEnv from "@/lib/env-entry";
import { GetServerMonitor } from "@/lib/serverFetch";
import { redirect } from "next/navigation";
import { NextResponse } from "next/server";
export const runtime = "edge";
@ -15,7 +16,7 @@ interface NezhaDataResponse {
export const GET = auth(async function GET(req) {
if (!req.auth && getEnv("SitePassword")) {
return NextResponse.json({ message: "Not authenticated" }, { status: 401 });
redirect("/api/auth/signin");
}
const { searchParams } = new URL(req.url);

View File

@ -2,6 +2,7 @@ import { ServerApi } from "@/app/[locale]/types/nezha-api";
import { auth } from "@/auth";
import getEnv from "@/lib/env-entry";
import { GetNezhaData } from "@/lib/serverFetch";
import { redirect } from "next/navigation";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
@ -15,7 +16,7 @@ interface NezhaDataResponse {
export const GET = auth(async function GET(req) {
if (!req.auth && getEnv("SitePassword")) {
return NextResponse.json({ message: "Not authenticated" }, { status: 401 });
redirect("/api/auth/signin");
}
const response = (await GetNezhaData()) as NezhaDataResponse;