implement app embedding as middleware