mirror of
https://github.com/shadcn-ui/taxonomy
synced 2026-05-23 17:28:23 +00:00
15 lines
363 B
TypeScript
15 lines
363 B
TypeScript
import { Session } from "next-auth"
|
|
|
|
export async function getSession(cookie: string): Promise<Session> {
|
|
const response = await fetch(`${process.env.NEXTAUTH_URL}/api/auth/session`, {
|
|
headers: { cookie },
|
|
})
|
|
|
|
if (!response?.ok) {
|
|
return null
|
|
}
|
|
|
|
const session = await response.json()
|
|
|
|
return Object.keys(session).length > 0 ? session : null
|
|
}
|