|
1 | 1 | // Imports
|
2 | 2 | // ========================================================
|
3 | 3 | import type { NextApiRequest, NextApiResponse } from "next";
|
4 |
| -import NextAuth, { type NextAuthOptions } from "next-auth"; |
| 4 | +import NextAuth from "next-auth"; |
| 5 | +import { type NextAuthOptions } from "next-auth"; |
5 | 6 | import { authOptions } from "@/server/auth";
|
6 | 7 |
|
7 | 8 | // Auth
|
8 | 9 | // ========================================================
|
9 |
| -const Auth = (req: NextApiRequest, res: NextApiResponse) => { |
| 10 | +const Auth = async (req: NextApiRequest, res: NextApiResponse) => { |
| 11 | + console.log("In [...nextauth].ts"); |
| 12 | + |
10 | 13 | const authOpts: NextAuthOptions = authOptions({ req });
|
11 | 14 |
|
| 15 | + if (!Array.isArray(req.query.nextauth)) { |
| 16 | + res.status(400).send("Bad request"); |
| 17 | + return; |
| 18 | + } |
| 19 | + |
12 | 20 | const isDefaultSigninPage =
|
13 |
| - req.method === "GET" && req?.query?.nextauth?.includes("signin"); |
| 21 | + req.method === "GET" && req.query.nextauth?.includes("signin"); |
14 | 22 |
|
15 | 23 | // Hide Sign-In with Ethereum from default sign page
|
16 | 24 | if (isDefaultSigninPage) {
|
17 | 25 | // Removes from the authOptions.providers array
|
18 | 26 | authOpts.providers.pop();
|
19 | 27 | }
|
20 | 28 |
|
21 |
| - return NextAuth(req, res, authOpts) as typeof NextAuth; |
| 29 | + return (await NextAuth(req, res, authOpts)) as typeof NextAuth; |
22 | 30 | };
|
23 | 31 |
|
24 | 32 | // Exports
|
|
0 commit comments