Capture NODE_ENV at middleware creation