Exposes function to serve middlewares
Sets env beta if local