Async Middleware - No active Pinia
See original GitHub issueEnvironment
- Operating System:
Linux
- Node Version:
v16.14.2
- Nuxt Version:
3.0.0-27484505.9f6eff7
- Package Manager:
yarn@1.22.18
- Builder:
vite
- User Config:
vite
,privateRuntimeConfig
,publicRuntimeConfig
,css
,buildModules
,intlify
,vueuse
- Runtime Modules:
-
- Build Modules:
@pinia/nuxt@0.1.8
,@vueuse/nuxt@8.2.4
,@intlify/nuxt3@0.1.10
Reproduction
check-auth.global.ts
:
import { useUserStore } from "~/stores/user";
export default defineNuxtRouteMiddleware(async () => {
// check if user is authenticated by using cookie and pinia
const session = useCookie('laravel_session').value || null
const userStore = useUserStore();
await userStore.fetchUser();
})
Describe the bug
getActivePinia was called with no active Pinia. Did you forget to install pinia? const pinia = createPinia() app.use(pinia) This will fail in production.
Using async middleware, pinia is not getting started.
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Nuxt 3 - Async Middleware - No active Pinia #1212 - GitHub
const pinia = createPinia() app.use(pinia) This will fail in production. Using async middleware, pinia is not getting started. Additional information. No ...
Read more >Vue: Can't access Pinia Store in beforeEnter vue-router
However, I don't have access to the Pinia Store, which doesn't seem to be initialized yet, although it is called before in the...
Read more >Complex Vue 3 state management made easy with Pinia
Build a basic blog engine using Pinia, a state management tool for Vue apps, and its main features, including state, getters, and actions....
Read more >Using Modules and Pinia to structure Nuxt 3 app
So basically Pinia works in all places no matter where you import it in your application. If you import it in the module,...
Read more >Nuxt.js - Pinia
We added it to the context so you have access to it in asyncData() and fetch() : ... but if you need to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is this fixed @danielroe because the same problem continues to be in Stable version of nuxt 3
Are there any updates on this issue? I’m using RC 3 and this is still not working.