fix build error

This commit is contained in:
sijinhui 2024-10-03 00:14:44 +08:00
parent d86d5a1951
commit 0922a7fe76
4 changed files with 15 additions and 12 deletions

View File

@ -27,13 +27,10 @@ async function handle(
const get_access_token = await getAccessToken(); const get_access_token = await getAccessToken();
if (!get_access_token.ok) { if (!get_access_token.ok) {
return NextResponse.json( return NextResponse.json({ error: "获取access_token失败" }, {
{ error: "获取access_token失败" }, status: get_access_token.status,
{ statusText: get_access_token.statusText,
status: get_access_token.status, } as any);
statusText: get_access_token.statusText,
},
);
} }
const access_token = await get_access_token.text(); const access_token = await get_access_token.text();
@ -42,3 +39,5 @@ async function handle(
export const GET = handle; export const GET = handle;
// export const POST = handle; // export const POST = handle;
export const runtime = "edge";

View File

@ -1,6 +1,7 @@
import LoginByGithub from "./loginByGithub"; import LoginByGithub from "./loginByGithub";
import LoginByGoogle from "./loginByGoogle"; import LoginByGoogle from "./loginByGoogle";
import UserLoginCore from "./user-login-core"; import UserLoginCore from "./user-login-core";
import { Suspense } from "react";
export default function LoginPage() { export default function LoginPage() {
return ( return (
@ -14,7 +15,9 @@ export default function LoginPage() {
{/*>*/} {/*>*/}
{/* */} {/* */}
{/*</Suspense>*/} {/*</Suspense>*/}
<UserLoginCore /> <Suspense>
<UserLoginCore />
</Suspense>
</div> </div>
<div className="mx-auto mt-4 w-11/12 max-w-xs sm:w-full inline-flex items-center justify-center"> <div className="mx-auto mt-4 w-11/12 max-w-xs sm:w-full inline-flex items-center justify-center">
{/*<Suspense*/} {/*<Suspense*/}

View File

@ -25,8 +25,8 @@ export const authOptions: NextAuthOptions = {
secret: process.env.NEXTAUTH_SECRET, secret: process.env.NEXTAUTH_SECRET,
providers: [ providers: [
Github({ Github({
clientId: process.env.AUTH_GITHUB_ID as string, clientId: process.env.AUTH_GITHUB_ID ?? "",
clientSecret: process.env.AUTH_GITHUB_SECRET as string, clientSecret: process.env.AUTH_GITHUB_SECRET ?? "",
profile(profile) { profile(profile) {
return { return {
id: profile.id.toString(), id: profile.id.toString(),
@ -129,8 +129,8 @@ export const authOptions: NextAuthOptions = {
} }
}), }),
Google({ Google({
clientId: process.env.GOOGLE_CLIENT_ID, clientId: process.env.GOOGLE_CLIENT_ID ?? "",
clientSecret: process.env.GOOGLE_CLIENT_SECRET, clientSecret: process.env.GOOGLE_CLIENT_SECRET ?? "",
allowDangerousEmailAccountLinking: true, allowDangerousEmailAccountLinking: true,
}), }),
], ],

View File

@ -25,6 +25,7 @@ declare module "next-auth" {
gh_username?: string; gh_username?: string;
password?: string; password?: string;
isAdmin?: boolean; isAdmin?: boolean;
allowToLogin?: boolean;
} }
} }