Before setting uri, check if we're running in a route

Otherwise in scripts/tests we get a crash