Middleware Registration Troubleshooting

This troubleshooting guide will help you debug why your middleware is not being registered correctly.

Incorrect Middleware File Name#

A common mistake when creating middlewares is naming the file middleware.ts rather than middlewares.ts.

If your middleware isn't registered correctly, make sure you've created the middleware file at src/api/middlewares.ts.

Learn more in the Middleware documentation.

Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵