mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-24 07:26:50 +00:00
登录-clerk方案
This commit is contained in:
18
pages/api/user.ts
Normal file
18
pages/api/user.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
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) {
|
||||
const user = getAuth(req)
|
||||
const { userId } = user
|
||||
if (!userId) {
|
||||
return res.status(401).json({ error: 'Unauthorized' })
|
||||
}
|
||||
|
||||
// retrieve data from your database
|
||||
res.status(200).json({ userId })
|
||||
}
|
||||
Reference in New Issue
Block a user