auth.client.js 385 B

1234567891011
  1. // noinspection JSUnusedGlobalSymbols
  2. export default defineNuxtPlugin(async (nuxtApp) => {
  3. if (!nuxtApp.payload.serverRendered) {
  4. await useAuthClient().fetchSession()
  5. } else if (nuxtApp.payload.prerenderedAt || nuxtApp.payload.isCached) {
  6. // To avoid hydration mismatch
  7. nuxtApp.hook("app:mounted", async () => {
  8. await useAuthClient().fetchSession()
  9. })
  10. }
  11. })