mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-03 00:26:40 +08:00
fix bug edge runtime
This commit is contained in:
parent
847bf8928f
commit
94bc0fa732
@ -3,12 +3,23 @@ import { Metadata } from "next";
|
|||||||
import { ReactNode } from "react";
|
import { ReactNode } from "react";
|
||||||
import { AntdRegistry } from "@ant-design/nextjs-registry";
|
import { AntdRegistry } from "@ant-design/nextjs-registry";
|
||||||
// import Head from "next/head";
|
// import Head from "next/head";
|
||||||
|
import { VerifiedAdminUser, VerifiedUser } from "@/lib/auth";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Admin | 管理页面",
|
title: "Admin | 管理页面",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function AdminLayout({ children }: { children: ReactNode }) {
|
export default async function AdminLayout({
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
children: ReactNode;
|
||||||
|
}) {
|
||||||
|
const isAdmin = await VerifiedAdminUser();
|
||||||
|
if (!isAdmin) {
|
||||||
|
redirect("/");
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AntdRegistry>
|
<AntdRegistry>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import "@/app/app/login.scss";
|
import "@/app/app/login.scss";
|
||||||
import { Metadata } from "next";
|
import { Metadata } from "next";
|
||||||
import { ReactNode } from "react";
|
import { ReactNode } from "react";
|
||||||
// import { VerifiedUser } from "@/lib/auth";
|
import { VerifiedUser } from "@/lib/auth";
|
||||||
// import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Login | 实人认证",
|
title: "Login | 实人认证",
|
||||||
@ -13,11 +13,11 @@ export default async function AuthLayout({
|
|||||||
}: {
|
}: {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
// const isUser = await VerifiedUser();
|
const isUser = await VerifiedUser();
|
||||||
// if (isUser) {
|
if (isUser) {
|
||||||
// // Replace '/dashboard' with the desired redirect path
|
// Replace '/dashboard' with the desired redirect path
|
||||||
// redirect("/");
|
redirect("/");
|
||||||
// }
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container1 w-full signin">
|
<div className="container1 w-full signin">
|
||||||
|
14
app/page.tsx
14
app/page.tsx
@ -4,18 +4,16 @@ import { Home } from "./components/home";
|
|||||||
|
|
||||||
import { getServerSideConfig } from "./config/server";
|
import { getServerSideConfig } from "./config/server";
|
||||||
|
|
||||||
// import { getSession } from "@/lib/auth";
|
import { VerifiedUser } from "@/lib/auth";
|
||||||
// import { isName } from "@/lib/auth_list";
|
import { redirect } from "next/navigation";
|
||||||
// import { redirect } from "next/navigation";
|
|
||||||
|
|
||||||
const serverConfig = getServerSideConfig();
|
const serverConfig = getServerSideConfig();
|
||||||
|
|
||||||
export default async function App() {
|
export default async function App() {
|
||||||
// const session = await getSession();
|
const isUser = await VerifiedUser();
|
||||||
// const name = session?.user?.email || session?.user?.name;
|
if (!isUser) {
|
||||||
// if (!(name && isName(name))) {
|
redirect("/login");
|
||||||
// redirect("/login");
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -44,23 +44,6 @@ export default async function middleware(req: NextRequest) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (req.method == 'POST' && (path.startsWith("/api/openai/") || path.startsWith("/api/midjourney"))) {
|
|
||||||
// // 重写header,添加用户名
|
|
||||||
// // console.log(session,'========')
|
|
||||||
// const requestHeaders = new Headers(req.headers)
|
|
||||||
//
|
|
||||||
// // 使用 encodeURIComponent 对特殊字符进行编码
|
|
||||||
// // 将编码的 URI 组件转换成 Base64
|
|
||||||
// const encodeName = Buffer.from(encodeURIComponent(`${session?.name}`)).toString('base64');
|
|
||||||
//
|
|
||||||
// requestHeaders.set('x-request-name', encodeName)
|
|
||||||
// return NextResponse.next({
|
|
||||||
// request: {
|
|
||||||
// // New request headers
|
|
||||||
// headers: requestHeaders,
|
|
||||||
// },
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
return NextResponse.next()
|
return NextResponse.next()
|
||||||
}
|
}
|
||||||
@ -72,3 +55,5 @@ export const config = {
|
|||||||
"/((?!api/logs/|api/auth/|_next/|_static/|_vercel|[\\w-]+\\.\\w+).*)",
|
"/((?!api/logs/|api/auth/|_next/|_static/|_vercel|[\\w-]+\\.\\w+).*)",
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 发现中间件在边缘网络中才生效,自己部署的docker不行
|
||||||
|
Loading…
Reference in New Issue
Block a user