Discussion

Ask a Question
Back to All

Custom Mashup with jQuery AJAX request to GitHub is failing

In a custom mashup we make a request to GitHub. These requests have recently started failing. The request failes with the following error:

Request header field Cache-Control is not allowed by Access-Control-Allow-Headers in preflight response.

This appears to be related to the fact that GitHub is setting the following:

Access-Control-Allow-Headers:Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Accept-Encoding, X-GitHub-OTP, X-Requested-With

We believe that the following code is causing the issue. Is there a way to disable the prefilter that sets the Cache-Control header?

)("~/JavaScript/Mashups/Common/HDRegistration/mashup.config.js");
(function(path) {
    try {
        var tau = {
            mashups: new Mashups()
        };
        tau.mashups.setPlaceholder("RestUI_Board", null, "/JavaScript/Mashups/Common/header_cache_clear/", path);
        /*~/JavaScript/Mashups/Common/header_cache_clear/header_cache_clear.js*/
        $.ajaxPrefilter(function(options, originalOptions, jqXHR) {
            if (options.url && (options.url.indexOf('viewgallery.tpondemand.net') >= 0 || options.url.indexOf('webident.targetprocess.com') >= 0)) {
                return;
            }
            if (!options.headers) {
                options.headers = {};
            }
            options.headers['Cache-Control'] = 'max-age=0';
        });
    } catch (e) {
        trackFailedMashup(path, e);
    }
}