window.postWithHeader = function(url, method, headerKey, headerValue) {
    fetch(url, {
        method: method,
        headers: {
            [headerKey] : headerValue
        }
    }).then(res => {
        if (res.redirected) {
            window.location.href = res.url;
        }
    });
};