Middleware now depends on environment