proxy not supported for some time. The assembly fails, the last commit fails the tests. The source of the stack trace from here on line 233 is the library code with the error.
Writing a similar proxy file is trivial. The following code illustrates how to create it.
const http = require('http'); const urlP = require('url'); const proxiedServer = 'http://localhost:8888'; // Proxy server http.createServer((req, res) => { console.log(`Proxy: Got ${req.url}`); const _r = http.request( Object.assign( {}, urlP.parse(proxiedServer), { method: req.method, path: req.url } ), _res => { res.writeHead(_res.statusCode, _res.headers); _res.pipe(res); } ); req.pipe(_r); }).listen(3124, () => { console.log("Listening on 3124"); }); // Regular server. Could be Express http.createServer((req, res) => { console.log('Proxied server: ', req.url); let b = ''; req.on('data', c => { b += c; }); req.on('end', () => { console.log('Proxied server: ', b); }); res.writeHead(200); res.end('ok'); }).listen(8888, () => { console.log('proxied server listening on 8888'); });
Your code using your own proxy will look like this:
const urlP = require('url'); const path = require('path'); const http = require('http'); const connect = require('connect'); const har = require('./har'); const proxiedServer = 'http://localhost:8888'; // Proxy server http.createServer((req, res) => { console.log(`Proxy: Got ${req.url}`); const _r = http.request( Object.assign( {}, urlP.parse(proxiedServer), { method: req.method, path: req.url } ), _res => { res.writeHead(_res.statusCode, _res.headers); _res.pipe(res); } ); req.pipe(_r); }).listen(3124, () => { console.log("Listening on 3124"); }); const middleware = connect(); middleware.use(har({ harOutputDir: path.resolve(process.cwd(), 'har/') })); middleware.use((req, res) => { console.log('Proxied server: ', req.url); let b = ''; req.on('data', c => { b += c; }); req.on('end', () => { console.log('Proxied server: ', b); }); res.writeHead(200); res.end('ok'); }); http.createServer(middleware).listen(8888, () => { console.log('proxied server listening on 8888'); });
source share