Answer by Govind Kumar worked, however, it only returned the URL if /page/{pagenum}/ was present in the URL and returned nothing if not. I needed a universal solution that will always return the base URL without pagination, so I modified Govind's code a bit and wrapped into a function:
function get_nopaging_url() {
global $wp;
$current_url = home_url( $wp->request );
$position = strpos( $current_url , '/page' );
$nopaging_url = ( $position ) ? substr( $current_url, 0, $position ) : $current_url;
return trailingslashit( $nopaging_url );
}
echo get_nopaging_url();
Now, it always returns correct URL.
(This is useful if you need to implement some kind of post filters that add a param to filter posts by, let's say, a meta filed. So, even if a user sets the filter param on page X, the new filtered results will always start from the base URL, not page X and throwing 404 if there's less filtered posts.)