I played around a bit, and putting this in config.php worked for me in my Valet environment:
'url' => isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? 'http://' . $_SERVER['HTTP_X_FORWARDED_HOST'] : 'http://your_localhost_domain',
Ideally, you would probably put this into your localhost config.
This even works with changing URLs.