diff --git a/app/(main)/layout.tsx b/app/(main)/layout.tsx
index 9df1909..8df46a4 100644
--- a/app/(main)/layout.tsx
+++ b/app/(main)/layout.tsx
@@ -8,16 +8,24 @@ import React from "react";
type DashboardProps = {
children: React.ReactNode;
};
-export default async function MainLayout({ children }: DashboardProps) {
- const session = await auth();
-
+export default function MainLayout({ children }: DashboardProps) {
return (
- {!session && getEnv("SitePassword") ? : children}
+ {children}
);
}
+
+async function AuthProtected({ children }: DashboardProps) {
+ if (getEnv("SitePassword")) {
+ const session = await auth();
+ if (!session) {
+ return ;
+ }
+ }
+ return children;
+}
diff --git a/app/api/detail/route.ts b/app/api/detail/route.ts
index 0cab16f..dc33171 100644
--- a/app/api/detail/route.ts
+++ b/app/api/detail/route.ts
@@ -14,10 +14,11 @@ interface ResError extends Error {
}
export async function GET(req: NextRequest) {
- const session = await auth();
-
- if (!session && getEnv("SitePassword")) {
- redirect("/");
+ if (getEnv("SitePassword")) {
+ const session = await auth();
+ if (!session) {
+ redirect("/");
+ }
}
const { searchParams } = new URL(req.url);
diff --git a/app/api/monitor/route.ts b/app/api/monitor/route.ts
index dec19aa..265af69 100644
--- a/app/api/monitor/route.ts
+++ b/app/api/monitor/route.ts
@@ -14,14 +14,16 @@ interface ResError extends Error {
}
export async function GET(req: NextRequest) {
- const session = await auth();
-
- if (!session && getEnv("SitePassword")) {
- redirect("/");
+ if (getEnv("SitePassword")) {
+ const session = await auth();
+ if (!session) {
+ redirect("/");
+ }
}
const { searchParams } = new URL(req.url);
const server_id = searchParams.get("server_id");
+
if (!server_id) {
return NextResponse.json(
{ error: "server_id is required" },
diff --git a/app/api/server/route.ts b/app/api/server/route.ts
index 04ef47c..ac4e64b 100644
--- a/app/api/server/route.ts
+++ b/app/api/server/route.ts
@@ -14,10 +14,11 @@ interface ResError extends Error {
}
export async function GET() {
- const session = await auth();
-
- if (!session && getEnv("SitePassword")) {
- redirect("/");
+ if (getEnv("SitePassword")) {
+ const session = await auth();
+ if (!session) {
+ redirect("/");
+ }
}
try {
diff --git a/app/layout.tsx b/app/layout.tsx
index a4deb23..9fb6075 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -48,7 +48,7 @@ export default async function LocaleLayout({
return (
-
+ {!process.env.VERCEL && !process.env.CF_PAGES && }