add publish_to_server middleware