diff --git a/next.config.js b/next.config.js index ce46d750..b586de22 100644 --- a/next.config.js +++ b/next.config.js @@ -58,6 +58,9 @@ function scanSubdirectories(directory) { */ const nextConfig = { + eslint: { + ignoreDuringBuilds: true + }, output: process.env.EXPORT ? 'export' : undefined, // 多语言, 在export时禁用 i18n: process.env.EXPORT diff --git a/pages/api/user.ts b/pages/api/user.ts index f60905c0..13fb3026 100644 --- a/pages/api/user.ts +++ b/pages/api/user.ts @@ -1,18 +1,24 @@ import { getAuth } from '@clerk/nextjs/server' import type { NextApiRequest, NextApiResponse } from 'next' + /** - * clerk身份测试 + * Clerk 身份测试 * @param req * @param res * @returns */ export default function handler(req: NextApiRequest, res: NextApiResponse) { - const user = getAuth(req) - const { userId } = user - if (!userId) { - return res.status(401).json({ error: 'Unauthorized' }) - } + try { + const { userId } = getAuth(req) - // retrieve data from your database - res.status(200).json({ userId }) + if (!userId) { + return res.status(401).json({ error: 'Unauthorized' }) + } + + // Retrieve data from your database + res.status(200).json({ userId }) + } catch (error) { + console.error(error) + res.status(500).json({ error: 'Internal Server Error' }) + } }