<commit_before>var httpProxy   = require('http-proxy');

var httpProxyMiddleware = function (context, opts) {

    var proxyOptions = opts || {};
    var proxy = httpProxy.createProxyServer(proxyOptions);

    console.log('[http-proxy-middleware] Proxy created:', context, proxyOptions.target);

    return fnProxyMiddleWare;

    function fnProxyMiddleWare (req, res, next) {
       if (hasContextInUrl(context, req.url)) {
           proxy.web(req, res);
       } else {
           next();
       }
    }

    function hasContextInUrl (context, url) {
        return url.indexOf(context) > -1;
    }

};<commit_msg>Proxy 'host' in request headers<commit_after>var httpProxy   = require('http-proxy');

var httpProxyMiddleware = function (context, opts) {

    var proxyOptions = opts || {};
    var proxy = httpProxy.createProxyServer(proxyOptions);

    console.log('[http-proxy-middleware] Proxy created:', context, proxyOptions.target);

    proxy.on('proxyReq', proxyReqHost);

    return fnProxyMiddleWare;

    function fnProxyMiddleWare (req, res, next) {
       if (hasContextInUrl(context, req.url)) {
           proxy.web(req, res);
       } else {
           next();
       }
    }

    function hasContextInUrl (context, url) {
        return url.indexOf(context) > -1;
    }

    function proxyReqHost (proxyReq, req, res, options) {
        var host = options.target.host;
        if (host) {
            proxyReq.setHeader('host', host);
        }
    }

};
{'fraction_non_alphanumeric': 0.12686567164179105, 'fraction_numerical': 0.0013568521031207597, 'mean_word_length': 2.7341772151898733, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7399510', 'n_tokens_mistral': 451, 'n_tokens_neox': 436, 'n_words': 99}