Having trouble with domain mapping plugin and cloudflare

I set up the following page rule. Please see the image.

Set up some special things to ignore caching in a mu plugin so that if something is in the cart it doesn't do caching.

$regex_path_match = '#^/wp-admin/?#';
$regex_path_match_2 = '#^/dm-sso-endpoint/?#';
$regex_path_match_3 = '#^bombfirst?#';
global $user_identity, $user_ID;
// https://domain.com/dm-sso-endpoint/1507583369/?dm_action=domainmap-setup-cdsso
//__domainmap_action=domainmap-authorize-user
if ( $user_ID ) {
header("Cache-Control: private, max-age=3600");
}
if ( preg_match($regex_path_match_3, $_SERVER['HTTP_HOST'])
|| preg_match($regex_path_match_2, $_SERVER['REQUEST_URI'])
|| isset($_GET['dm_action'])
|| ( $_GET['__domainmap_action'] == 'domainmap-authorize-user' && isset($_GET['auth']) )
|| isset($user_ID) || isset($_GET['et_fb'])
|| preg_match($regex_path_match, $_SERVER['REQUEST_URI'])
|| isset($_COOKIE['woocommerce_items_in_cart'])
) {
add_action( 'send_headers', 'add_header_nocache', 15 );
}
function add_header_nocache() {
header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
}

here's the problem...domain mapping redirect. If somebody tries to login an infinate loop occurs. No problems if not logged in and no problems with woocommerce. Trying to understand what i'm missing to get around that.

the issue is how domain mapping does this:
in the file: wp-content/plugins/domain-mapping/classes/Domainmap/Module/Cdsso.php
line 569 wp_redirect( esc_url_raw( $redirect_to ) );
which is part of:

function authorize_user() {

if ( filter_input( INPUT_GET, self::ACTION_KEY ) == self::ACTION_AUTHORIZE_USER ) {
$user_id = wp_validate_auth_cookie( filter_input( INPUT_GET, 'auth' ), 'auth' );
if ( $user_id ) {
wp_set_auth_cookie( $user_id );

$redirect_to = in_array( $GLOBALS['pagenow'], array( 'wp-login.php' ) ) && filter_input( INPUT_GET, 'redirect_to', FILTER_VALIDATE_URL )
? $_GET['redirect_to']
: add_query_arg( array( self::ACTION_KEY => false, 'auth' => false ) );

$redirect_to = apply_filters("dm_sync_sso_redirect", $redirect_to);

wp_redirect( esc_url_raw( $redirect_to ) );
exit;
} else {
wp_die( __( 'Incorrect or out of date login key', 'domainmap' ) );
}
}
}

It's somehow getting messed up from cache and not able to set its cookie or whatever it needs to do.