Skip to content

Commit

Permalink
refactor: update server fetch and config with minor optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
hamster1963 committed Jan 25, 2025
1 parent 527bf45 commit f7b081f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/api/server-ip/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function GET(req: NextRequest) {
}

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)
Expand Down
9 changes: 7 additions & 2 deletions lib/serverFetch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import type { NezhaAPI, ServerApi } from "@/app/types/nezha-api"
import type { MakeOptional } from "@/app/types/utils"
import getEnv from "@/lib/env-entry"
import { unstable_noStore as noStore } from "next/cache"
import { connection } from 'next/server'

export async function GetNezhaData() {
noStore()
await connection()

let nezhaBaseUrl = getEnv("NezhaBaseUrl")
if (!nezhaBaseUrl) {
Expand Down Expand Up @@ -87,6 +87,8 @@ export async function GetNezhaData() {
}

export async function GetServerMonitor({ server_id }: { server_id: number }) {
await connection()

let nezhaBaseUrl = getEnv("NezhaBaseUrl")
if (!nezhaBaseUrl) {
console.error("NezhaBaseUrl is not set")
Expand Down Expand Up @@ -131,6 +133,8 @@ export async function GetServerIP({
}: {
server_id: number
}): Promise<string> {
await connection()

let nezhaBaseUrl = getEnv("NezhaBaseUrl")
if (!nezhaBaseUrl) {
console.error("NezhaBaseUrl is not set")
Expand Down Expand Up @@ -178,6 +182,7 @@ export async function GetServerIP({
}

export async function GetServerDetail({ server_id }: { server_id: number }) {
await connection()
let nezhaBaseUrl = getEnv("NezhaBaseUrl")
if (!nezhaBaseUrl) {
console.error("NezhaBaseUrl is not set")
Expand Down
2 changes: 0 additions & 2 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import withPWAInit from "@ducanh2912/next-pwa"
import withBundleAnalyzer from "@next/bundle-analyzer"
import createNextIntlPlugin from "next-intl/plugin"
import { env } from "next-runtime-env"

const bundleAnalyzer = withBundleAnalyzer({
enabled: process.env.ANALYZE === "true",
Expand Down Expand Up @@ -29,7 +28,6 @@ const nextConfig = {
},
},
output: "standalone",
poweredByHeader: false,
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
Expand Down

0 comments on commit f7b081f

Please sign in to comment.