streaming, markdown, model selecting, and lots more
This commit is contained in:
@@ -2,10 +2,24 @@ export default defineNuxtPlugin({
|
||||
name: 'better-auth-fetch-plugin',
|
||||
enforce: 'pre',
|
||||
async setup(nuxtApp) {
|
||||
const triplit = useTriplitClient();
|
||||
|
||||
// Flag if request is cached
|
||||
nuxtApp.payload.isCached = Boolean(useRequestEvent()?.context.cache)
|
||||
nuxtApp.payload.isCached = Boolean(useRequestEvent()?.context.cache);
|
||||
if (nuxtApp.payload.serverRendered && !nuxtApp.payload.prerenderedAt && !nuxtApp.payload.isCached) {
|
||||
await useAuth().fetchSession()
|
||||
const { session, fetchSession } = useAuth();
|
||||
|
||||
if (!session.value) {
|
||||
await fetchSession();
|
||||
}
|
||||
|
||||
if (!session.value) return;
|
||||
|
||||
if ('updateOptions' in triplit) {
|
||||
triplit.updateOptions({
|
||||
token: session.value.token,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user