fix bug edge runtime

This commit is contained in:
sijinhui
2024-04-07 11:14:04 +08:00
parent 847bf8928f
commit 94bc0fa732
4 changed files with 27 additions and 33 deletions

View File

@@ -3,12 +3,23 @@ import { Metadata } from "next";
import { ReactNode } from "react";
import { AntdRegistry } from "@ant-design/nextjs-registry";
// import Head from "next/head";
import { VerifiedAdminUser, VerifiedUser } from "@/lib/auth";
import { redirect } from "next/navigation";
export const metadata: Metadata = {
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 (
<>
<AntdRegistry>

View File

@@ -1,8 +1,8 @@
import "@/app/app/login.scss";
import { Metadata } from "next";
import { ReactNode } from "react";
// import { VerifiedUser } from "@/lib/auth";
// import { redirect } from "next/navigation";
import { VerifiedUser } from "@/lib/auth";
import { redirect } from "next/navigation";
export const metadata: Metadata = {
title: "Login | 实人认证",
@@ -13,11 +13,11 @@ export default async function AuthLayout({
}: {
children: ReactNode;
}) {
// const isUser = await VerifiedUser();
// if (isUser) {
// // Replace '/dashboard' with the desired redirect path
// redirect("/");
// }
const isUser = await VerifiedUser();
if (isUser) {
// Replace '/dashboard' with the desired redirect path
redirect("/");
}
return (
<div className="container1 w-full signin">