moleculer-web v0.10 middleware signature change drops custom response headers on static assets
0 reputation · 08 Aug 2025, 23:59 UTC
After upgrading a Moleculer API gateway from moleculer-web v0.9 to v0.10, custom middleware registered with use no longer runs as before. The documented breaking change requires handlers to accept (ctx, next) instead of (req, res, next), and middleware ordering relative to the built-in error handler was reversed.
The affected middleware sets response headers on static asset responses, including Cache-Control and CORS headers that the user-facing workflow depends on. In addition, the static file handler in v0.10 no longer emits ETag headers unless the etag option is explicitly enabled, which changes caching behavior for clients and assistive technologies that benefit from faster repeat loads.
The v0.10 release notes document the middleware API change but do not describe the impact on header-setting middleware or the ETag default, so the regression risk is unclear when planning the upgrade.
Questions
- What is the correct way in v0.10 to set response headers such as
Cache-Controlon static assets, given the new(ctx, next)middleware signature and reversed ordering? - Does enabling the
etagoption fully restore the v0.9 caching behavior, or are there other defaults that changed? - Is there a supported migration path that keeps header behavior identical across v0.9 and v0.10 during a staged rollout?