Refactor to allow api access to users not connected to localhost.