<script>
    /*
     * A callback for cf-util-http to proxy all calls to our backend
     *
     * @param {Object} [opts]
     * @param {String} [opts.method] - GET/POST/PUT/PATCH/DELETE
     * @param {String} [opts.url]
     * @param {Object} [opts.parameters]
     * @param {Object} [opts.headers]
     * @param {Object} [opts.body]
     * @param {Function} [opts.onSuccess]
     * @param {Function} [opts.onError]
     */
    var absoluteUrlBase = '<?php echo $this->getRestProxyPrefix(); ?>';
    var proxyUrl = '<?php echo $this->getProxyUrl(); ?>';
    localStorage.cfEmail = '<?php echo $this->getCloudflareEmail(); ?>';
    function RestProxyCallback(opts) {
        //only proxy external REST calls
        if(opts.url.lastIndexOf("http", 0) === 0) {
            if(!opts.parameters) {
                opts.parameters = {};
            }
            if(!opts.body) {
                opts.body = {};
            }
            if(opts.method.toUpperCase() !== "GET") {
                opts.body['proxyURL'] = opts.url;
                //Magento CSRF token
                opts.body['form_key'] = window.FORM_KEY;
            } else {
                opts.parameters['proxyURL'] = opts.url;
            }
            opts.url = proxyUrl;
            opts.parameters['isAjax'] = true;
        } else {
            opts.url = absoluteUrlBase + opts.url;
        }
    }
</script>
<!-- <?php echo $this->getFormKey();?> -->
<div id="root" class="cloudflare-partners"></div>
<script src="<?php echo $this->getCompiledJsUrl(); ?>"></script>