Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Ensure that session middleware is always first #44

Open
2 tasks
BracketJohn opened this issue Nov 27, 2022 · 0 comments
Open
2 tasks

Ensure that session middleware is always first #44

BracketJohn opened this issue Nov 27, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@BracketJohn
Copy link
Contributor

Describe the feature

Currently, we attempt to ensure that the server session middleware is always first by using .unshit to register it:

// 4. Setup middleware, use `.unshift` to ensure (reasonably well) that the session middleware is first
const handler = resolve('./runtime/server/middleware/session')
const serverHandler = {
middleware: true,
handler
}
nuxt.options.serverHandlers.unshift(serverHandler)

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:

  • always register session middleware first
    • with reasonable precision
    • optional: allow user to set order (this could be helpful with other modules that should come before / after this session middleware)

Additional information

No response

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant