Since it's the same middleware as in development, create a named function and use it in both environments.