Gary
Trying to use pinia store in plugin provided by custom module
I have a custom module that has begun to fail outside of it's own playground since updating to nuxt 3.16.2. The problem is that when workign on the module the playground runs as expected. After building and importing into a local project we get the dreaded:
Uncaught Error: [:pineapple:]: "getActivePinia()" was called but there was no active Pinia.
error from pinia.
Our plugin looks like this:
```typescript
export default defineNuxtPlugin(async (NuxtApp) => {
const voixConfig = useRuntimeConfig().public.voix.options as unknown as VoixModuleOptionsInterface
const voixOptions = Object.assign({}, voixConfig)
if (!voixOptions.languages?.length) {
voixOptions.languages = [
{
code: 'en',
name: 'English',
icon: '🇺🇸',
},
]
}
let voix: IVoix = {
options: voixOptions,
breakpoint: ref(''),
}
const sliceStore = useSliceStore()
// eslint-disable-next-line ts/no-unsafe-assignment
sliceStore.slices = slicesConfig
const layoutStore = useLayoutStore()
// eslint-disable-next-line ts/no-unsafe-assignment
layoutStore.layouts = layoutsConfig
NuxtApp.vueApp.directive('voix-text', vVoixText)
NuxtApp.vueApp.directive('voix-text-color', vVoixTextColor)
NuxtApp.vueApp.directive('voix-background-color', vVoixBackgroundColor)
NuxtApp.vueApp.directive('voix-visibility', vVoixVisibility)
NuxtApp.vueApp.directive('voix-popper', vVoixPopper)
voix = voixBreakpointsSetup(voix)
voix = voixFetchSetup(voix)
voix = voixEventsSetup(voix)
authMiddlewareSetup()
voixApplicationSetup()
// Injects into the application for global use
return {
provide: {
voix,
},
}
})7 replies
Is it possible to have Nitro update when virtual modules are invalidated during handleHotUpdate?
From a custom vite plugin the following works great:
Client side responds appropriately but I can't seem to get the SSR to see the changes in the virtual module. On reload it loads the old info and then hydrates with the correct info.
Any help would be greatly appreciated!!!
Any help would be greatly appreciated!!!
5 replies
Simple Lambda Cookie Question
tldr: Do cookies work on initial page load on AWS Lambda?
Hey folks - building something for aws-lambda and everything is up and running except the
useCookie
method on initial load: I'm reading it in some routeMiddleware and looks something like this:
So, simple test to see if they are on any route other than pin-code
and if they are I read the cookie. If the cookie isnt there or it doesn't equal to my super secure password I redirect them to the pin-code page.
This works totally fine locally. On Lambda it works on any subsequent page as you click around and router is used. However, initial page load doesn't seem to be able to read the cookie. What am I missing?3 replies
Nitro routeRules shouldInvalidateCache
Not sure I understand how or why but from Nuxt nuxt.config.ts why do the shouldInvalidateCache and shouldBypassCache functions not work?
If I do the following:
Time never updates until the maxAge expires. I would imagine that cache would be invalidated every time the page loaded.
1 replies