Created
February 2, 2018 16:18
-
-
Save mauritslamers/a60710e7db5c39ffbb0cb061adc0354f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var proxyToelating = function (origReq, origResp, next) { | |
var url = origReq.url; | |
var path = require('url').parse(url).pathname; | |
var proxyReq; | |
console.log("Trying to proxying " + url); | |
var me = this; | |
if (origReq.headers.host) origReq.headers.host = ""; | |
origReq.headers['Authorization'] = "Basic myauth="; | |
proxyReq = require('https').request({ | |
hostname: "my.host.ext", | |
path: path, | |
method: origReq.method, | |
headers: origReq.headers, | |
agent: false | |
}, | |
function (proxyres) { | |
console.log(proxyres); | |
proxyres.pipe(origResp, { end: true }); | |
} | |
); | |
origReq.pipe(proxyReq, { end : true }); | |
} | |
/// further on | |
app.use('/webdav', proxyToelating); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment