feat(frontend): Use betterAuth implementation from nuxthub-better-auth project
This commit is contained in:
13
legalconsenthub/plugins/auth.server.ts
Normal file
13
legalconsenthub/plugins/auth.server.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copied from https://github.com/atinux/nuxthub-better-auth
|
||||
|
||||
export default defineNuxtPlugin({
|
||||
name: 'better-auth-fetch-plugin',
|
||||
enforce: 'pre',
|
||||
async setup(nuxtApp) {
|
||||
// Flag if request is cached
|
||||
nuxtApp.payload.isCached = Boolean(useRequestEvent()?.context.cache)
|
||||
if (nuxtApp.payload.serverRendered && !nuxtApp.payload.prerenderedAt && !nuxtApp.payload.isCached) {
|
||||
await useAuth().fetchSession()
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user