fix middleware for env=production