Relative links stop working after moving wordpress site from hosting to localhost

If you are in https://localhost/cc and use a relative lnk with href="https://wordpress.stackexchange.com/login" (relative to current domain/site), the browser (not WordPress) will take you to https://localhost/login; if the link is href="https://wordpress.stackexchange.com/questions/267557/login" (relative to current path) the browser will take you to https://localhost/cc/login.

Relative links work like that, nothing to do with WordPress. That is why many developers prefer to use absolute links, and WordPress too. You can get the home url and append the path you want like this:

// See https://developer.wordpress.org/reference/functions/home_url/
// Outputs http:://example.com/login
$login_url = home_url( "https://wordpress.stackexchange.com/questions/267557/login" );

If you prefer relative paths:

// Outputs /login
$login_url = home_url( "https://wordpress.stackexchange.com/questions/267557/login", 'relative' );

And the good thing of using this method is that you get paths relative to current site, not to current path. So, if you are in https://localhost/cc you get this result (which I think will work for you if you still wnat to use relative links):

// If we are in `https://localhost/cc`
// Outputs /cc/login
$login_url = home_url( "https://wordpress.stackexchange.com/questions/267557/login", 'relative' );