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

Ensure that session middleware is always first #44

Open
@BracketJohn

Description

@BracketJohn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions