mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 15:09:22 +00:00
25 lines
576 B
TypeScript
25 lines
576 B
TypeScript
import { getAuth } from '@clerk/nextjs/server'
|
|
import type { NextApiRequest, NextApiResponse } from 'next'
|
|
|
|
/**
|
|
* Clerk 身份测试
|
|
* @param req
|
|
* @param res
|
|
* @returns
|
|
*/
|
|
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
try {
|
|
const { userId } = getAuth(req)
|
|
|
|
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' })
|
|
}
|
|
}
|