Await dynamic APIs in auth server helpers
This commit is contained in:
parent
e491becbc4
commit
9cdd8763b4
2 changed files with 8 additions and 8 deletions
|
|
@ -8,14 +8,14 @@ import { isAdmin, isStaff } from "@/lib/authz"
|
|||
|
||||
type ServerSession = Awaited<ReturnType<typeof getCookieCache>>
|
||||
|
||||
function serializeCookies() {
|
||||
const store = cookies()
|
||||
async function serializeCookies() {
|
||||
const store = await cookies()
|
||||
return store.getAll().map((cookie) => `${cookie.name}=${cookie.value}`).join("; ")
|
||||
}
|
||||
|
||||
function buildRequest() {
|
||||
const cookieHeader = serializeCookies()
|
||||
const headerList = headers()
|
||||
async function buildRequest() {
|
||||
const cookieHeader = await serializeCookies()
|
||||
const headerList = await headers()
|
||||
const userAgent = headerList.get("user-agent") ?? ""
|
||||
const ip =
|
||||
headerList.get("x-forwarded-for") ||
|
||||
|
|
@ -35,7 +35,7 @@ function buildRequest() {
|
|||
|
||||
export async function getServerSession(): Promise<ServerSession | null> {
|
||||
try {
|
||||
const request = buildRequest()
|
||||
const request = await buildRequest()
|
||||
const session = await getCookieCache(request)
|
||||
return session ?? null
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue