Skip to content

fix(inertia-sails): inject inertiaContext middleware when order is not configured#194

Merged
DominusKelvin merged 3 commits into
mainfrom
fix/inertia-context-middleware-injection
Mar 6, 2026
Merged

fix(inertia-sails): inject inertiaContext middleware when order is not configured#194
DominusKelvin merged 3 commits into
mainfrom
fix/inertia-context-middleware-injection

Conversation

@DominusKelvin
Copy link
Copy Markdown
Member

Summary

  • Fix inertiaContext middleware not being injected when sails.config.http.middleware.order is not explicitly defined (the default for all Sails apps)
  • Initialize the middleware order with Sails' defaults when undefined, then inject inertiaContext before the router as intended

Context

The configure phase checked mw.order && ... which skipped injection entirely when order was undefined. This caused sails.inertia.share() in routes.before handlers to run outside AsyncLocalStorage context, silently dropping all shared props.

Test plan

  • Verified on a Sails app with default (commented-out) middleware order — no more warnings, inertiaContext correctly injected before router

Closes #193

…t configured

When sails.config.http.middleware.order is not explicitly defined (the
default for all Sails apps), the hook skipped injecting the
inertiaContext middleware entirely. This caused sails.inertia.share()
calls in routes.before handlers to run outside AsyncLocalStorage
context, silently dropping shared props.

Initialize the middleware order with Sails' defaults when undefined,
then inject inertiaContext before the router as intended.

Closes #193
@DominusKelvin DominusKelvin merged commit f06ad2a into main Mar 6, 2026
4 checks passed
@DominusKelvin DominusKelvin deleted the fix/inertia-context-middleware-injection branch March 6, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant