This function tries to do 301 redirects to the canonical URL if the hostname differs from the one set in WP_HOME. I did not know that this function existed. Why have I been doing canonical hostname redirects in server conf?
Bookmarked https://github.com/WordPress/wordpress-develop/blob/6.1/src/wp-includes/canonical.php#L42-L809.