mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
refactor: update server fetch and config with minor optimizations
This commit is contained in:
parent
527bf45f43
commit
f7b081fad4
@ -28,7 +28,7 @@ export async function GET(req: NextRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!getEnv("NEXT_PUBLIC_ShowIpInfo")) {
|
if (!getEnv("NEXT_PUBLIC_ShowIpInfo")) {
|
||||||
return NextResponse.json({ error: "NEXT_PUBLIC_ShowIpInfo is disable" }, { status: 400 })
|
return NextResponse.json({ error: "ip info is disabled" }, { status: 400 })
|
||||||
}
|
}
|
||||||
|
|
||||||
const { searchParams } = new URL(req.url)
|
const { searchParams } = new URL(req.url)
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
import type { NezhaAPI, ServerApi } from "@/app/types/nezha-api"
|
import type { NezhaAPI, ServerApi } from "@/app/types/nezha-api"
|
||||||
import type { MakeOptional } from "@/app/types/utils"
|
import type { MakeOptional } from "@/app/types/utils"
|
||||||
import getEnv from "@/lib/env-entry"
|
import getEnv from "@/lib/env-entry"
|
||||||
import { unstable_noStore as noStore } from "next/cache"
|
import { connection } from 'next/server'
|
||||||
|
|
||||||
export async function GetNezhaData() {
|
export async function GetNezhaData() {
|
||||||
noStore()
|
await connection()
|
||||||
|
|
||||||
let nezhaBaseUrl = getEnv("NezhaBaseUrl")
|
let nezhaBaseUrl = getEnv("NezhaBaseUrl")
|
||||||
if (!nezhaBaseUrl) {
|
if (!nezhaBaseUrl) {
|
||||||
@ -87,6 +87,8 @@ export async function GetNezhaData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function GetServerMonitor({ server_id }: { server_id: number }) {
|
export async function GetServerMonitor({ server_id }: { server_id: number }) {
|
||||||
|
await connection()
|
||||||
|
|
||||||
let nezhaBaseUrl = getEnv("NezhaBaseUrl")
|
let nezhaBaseUrl = getEnv("NezhaBaseUrl")
|
||||||
if (!nezhaBaseUrl) {
|
if (!nezhaBaseUrl) {
|
||||||
console.error("NezhaBaseUrl is not set")
|
console.error("NezhaBaseUrl is not set")
|
||||||
@ -131,6 +133,8 @@ export async function GetServerIP({
|
|||||||
}: {
|
}: {
|
||||||
server_id: number
|
server_id: number
|
||||||
}): Promise<string> {
|
}): Promise<string> {
|
||||||
|
await connection()
|
||||||
|
|
||||||
let nezhaBaseUrl = getEnv("NezhaBaseUrl")
|
let nezhaBaseUrl = getEnv("NezhaBaseUrl")
|
||||||
if (!nezhaBaseUrl) {
|
if (!nezhaBaseUrl) {
|
||||||
console.error("NezhaBaseUrl is not set")
|
console.error("NezhaBaseUrl is not set")
|
||||||
@ -178,6 +182,7 @@ export async function GetServerIP({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function GetServerDetail({ server_id }: { server_id: number }) {
|
export async function GetServerDetail({ server_id }: { server_id: number }) {
|
||||||
|
await connection()
|
||||||
let nezhaBaseUrl = getEnv("NezhaBaseUrl")
|
let nezhaBaseUrl = getEnv("NezhaBaseUrl")
|
||||||
if (!nezhaBaseUrl) {
|
if (!nezhaBaseUrl) {
|
||||||
console.error("NezhaBaseUrl is not set")
|
console.error("NezhaBaseUrl is not set")
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import withPWAInit from "@ducanh2912/next-pwa"
|
import withPWAInit from "@ducanh2912/next-pwa"
|
||||||
import withBundleAnalyzer from "@next/bundle-analyzer"
|
import withBundleAnalyzer from "@next/bundle-analyzer"
|
||||||
import createNextIntlPlugin from "next-intl/plugin"
|
import createNextIntlPlugin from "next-intl/plugin"
|
||||||
import { env } from "next-runtime-env"
|
|
||||||
|
|
||||||
const bundleAnalyzer = withBundleAnalyzer({
|
const bundleAnalyzer = withBundleAnalyzer({
|
||||||
enabled: process.env.ANALYZE === "true",
|
enabled: process.env.ANALYZE === "true",
|
||||||
@ -29,7 +28,6 @@ const nextConfig = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
poweredByHeader: false,
|
|
||||||
eslint: {
|
eslint: {
|
||||||
// Warning: This allows production builds to successfully complete even if
|
// Warning: This allows production builds to successfully complete even if
|
||||||
// your project has ESLint errors.
|
// your project has ESLint errors.
|
||||||
|
Loading…
Reference in New Issue
Block a user