I setup proxy middleware on express. Proxy work as expected with get request. But I can't use login form in anymore.
note: i have rewrite the form action url to my proxy manually.
var apiProxy = proxy('/proxy', {
target: 'https://m.facebook.com/',
changeOrigin: true,
pathRewrite: { '^/proxy/login.php': '/login.php' },
onProxyReq: (proxyReq, req, res) => {
proxyReq.setHeader( 'User-Agent', 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' );
}
});
var app = express();
app.use(apiProxy);
app.listen(3001);
Can you reproduce this in an isolated setup?
(without the m.facebook.com as target)
Even better if you can provide a working setup in a repo.
Having the same issue with POST proxys. Give a couple hours and I try to reproduce an example.
Issue has gone stale; Closing issue.
Feel free to re-open.
Thanks.
PS: I think StackOverflow would be a better place to troubleshoot your setup.
@chimurai I've met the same issue and after seeing this ticket, assumed this is a known problem that is going to be addressed. I'm not sure if I can extract a small repro from my project. Are POST requests actually supported by http-proxy-middleware?
POST requests are supported. Some issues might occur if your using body-parser for example. In those cases make sure you've configured/mount the proxy prior to the body-parser.
Thanks, I'm using body-parser indeed, I'll try your suggestion.
FYI - I just tried this - moving above bodyParser... Curious as to why this is necessary?
Most helpful comment
POST requests are supported. Some issues might occur if your using
body-parserfor example. In those cases make sure you've configured/mount the proxy prior to the body-parser.