sidebase / nuxt-session

Nuxt session middleware to get a persistent session per app user, e.g., to store data across multiple requests. The nuxt session module provides the useSession() composable out of the box and sets up API endpoints to interact with your session to make working with sessions feel like a breeze.
https://sidebase.io/nuxt-session/
MIT License
188 stars 19 forks source link

Ensure that session middleware is always first #44

Open BracketJohn opened 1 year ago

BracketJohn commented 1 year ago

Describe the feature

Currently, we attempt to ensure that the server session middleware is always first by using .unshit to register it: https://github.com/sidebase/nuxt-session/blob/f82d2c110f081d82de396e925e6b18f694ada8dd/src/module.ts#L80-L86

This attempt however does not work, as noticed by discord user Bark: https://discord.com/channels/1024643779711483944/1024705710455533598/1045816936359010326

With further investigation this does not work, as the module setup runs at "build time" before the user nuxt app, so at that point any user middlewares are not in the middleware array yet, so unshifting does not have any effect.

Goal:

Additional information

No response