fix: env script

This commit is contained in:
hamster1963 2024-09-22 16:40:04 +08:00
parent 5d01cd15b4
commit 66251f6cac
3 changed files with 5 additions and 2 deletions

View File

@ -8,7 +8,7 @@ import getEnv from "@/lib/env-entry";
export default function ServerListClient() { export default function ServerListClient() {
const { data } = useSWR<ServerApi>("/api/server", nezhaFetcher, { const { data } = useSWR<ServerApi>("/api/server", nezhaFetcher, {
refreshInterval: Number(getEnv('NEXT_PUBLIC_NezhaFetchInterval')) || 2000, refreshInterval: Number(getEnv("NEXT_PUBLIC_NezhaFetchInterval")) || 2000,
}); });
if (!data) return null; if (!data) return null;

View File

@ -6,6 +6,7 @@ import { ThemeProvider } from "next-themes";
import React from "react"; import React from "react";
import { Viewport } from "next"; import { Viewport } from "next";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { PublicEnvScript } from "next-runtime-env";
const fontSans = FontSans({ const fontSans = FontSans({
subsets: ["latin"], subsets: ["latin"],
@ -37,6 +38,9 @@ interface RootLayoutProps {
export default function RootLayout({ children }: RootLayoutProps) { export default function RootLayout({ children }: RootLayoutProps) {
return ( return (
<html lang="en" suppressHydrationWarning> <html lang="en" suppressHydrationWarning>
<head>
<PublicEnvScript />
</head>
<body <body
className={cn( className={cn(
"min-h-screen bg-background font-sans antialiased", "min-h-screen bg-background font-sans antialiased",

View File

@ -6,7 +6,6 @@ import { error } from "console";
import getEnv from "./env-entry"; import getEnv from "./env-entry";
export async function GetNezhaData() { export async function GetNezhaData() {
var nezhaBaseUrl = getEnv("NezhaBaseUrl"); var nezhaBaseUrl = getEnv("NezhaBaseUrl");
if (!nezhaBaseUrl) { if (!nezhaBaseUrl) {
error("NezhaBaseUrl is not set"); error("NezhaBaseUrl is not set");