chore: seminarhof customer project
This commit is contained in:
22
packages/functions/src/wirings/middleware.ts
Normal file
22
packages/functions/src/wirings/middleware.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { addHTTPMiddleware } from '#pikku'
|
||||
import { cors } from '@pikku/core/middleware'
|
||||
import { betterAuthSession } from '@pikku/better-auth'
|
||||
import { sessionCookieMiddleware } from '../middleware/session-cookie.js'
|
||||
|
||||
// sessionCookieMiddleware runs first so that booking-form clients
|
||||
// (sh_session cookie) are resolved before better-auth is checked.
|
||||
addHTTPMiddleware('*', [
|
||||
cors({
|
||||
origin: true,
|
||||
credentials: true,
|
||||
headers: ['Content-Type', 'Authorization', 'x-api-key', 'X-Auth-Return-Redirect'],
|
||||
}),
|
||||
sessionCookieMiddleware,
|
||||
betterAuthSession({
|
||||
mapSession: (result: any) => ({
|
||||
userId: result.user.id,
|
||||
role: result.user.role ?? 'client',
|
||||
locale: result.user.locale ?? 'de',
|
||||
}),
|
||||
}),
|
||||
])
|
||||
Reference in New Issue
Block a user