Hi,
I'm trying to setup a nodebb proxy in node.js, based on this code:
And it's sort of working, I can mostly browse the forum (looks great!) except it's failing when I try to login with the following error:
Login Unsuccessful
We were unable to log you in, likely due to an expired session. Please try again
I have changed "url" in config.json to: "https://skirmish-dev.net/forum", which is were I am browsing the forum from.
Weirdly, if I change it to "http://localhost:4567/forum", login starts working, even though there are some 'bad' urls in the returned page.
I have made sure to ./nodebb build after changing anything in config.json.
Here's my initProxy function, based on the above but modified a little to let the rest of the site run:
function initProxy(app) {
const proxyRules = new HttpProxyRules({
rules: {
'.*/forum': 'http://localhost:4567/forum', // Rule (2) forums
'.*/forum/*': 'http://localhost:4567/forum',
'/forum/*': 'http://localhost:4567/forum',
'./forum/*': 'http://localhost:4567/forum',
'/forum': 'http://localhost:4567/forum'
}
});
const proxy = httpProxy.createProxy();
app.use(function(req,res,next){
try{
if (req.url.substr(0, 18).indexOf("socket.io")>-1){
console.log("SOCKET.IO", req.url)
return proxy.web(req, res, { target: 'wss://localhost:4567', ws: true }, function(e) {
console.log('PROXY ERR',e)
});
} else {
var target = proxyRules.match(req);
if (target) {
console.log("TARGET", target)
return proxy.web(req, res, {target: target}, function(e) {
console.log('PROXY ERR',e)
});
} else {
next();
}
}
} catch(e){
res.sendStatus(500);
}
});
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
}
Anyone have any idea what's up?
Bye,
Mark