Why does form submit become json?
when I use express http proxy as follow filter: function (req, res) { var whiteList = req.url.match('^/wx/weixin') || req.url.match('^/wx/fans') || req.url.match('^/wx/app') || req.url.match('^/wx/css') || req.url.match('^/wx/font') || req.url.match('^/wx/img') || req.url.match('^/wx/js'); if (whiteList) { return true } return security.checkJWT(req, res) }, proxyReqPathResolver: function (req, res) { console.log('WX => ' + req.url); var begin = req.url.indexOf('/', 2); return req.url.substring(begin, req.url.length); }
My problem is: Without proxy My request is POST /weixin/saveMenuInfo HTTP/1.1 Host: localhost:5060 Connection: keep-alive Content-Length: 89 Accept: / Origin: http://localhost:9999 X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36 Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Accept-Encoding: gzip, deflate, br Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7,en-US;q=0.6 Cookie: JSESSIONID=5FFCF1947C09102D5637E250ACD4AC3D Referer: http://localhost:5060/weixin/customMenu
name=2323sdfsd&type=2&content=&imageMediaId=&newsMediaId=&url=3434&id=1&mediaId=&msgType=
Through proxy It became: POST /weixin/saveMenuInfo HTTP/1.1 accept: / origin: http://localhost:3000 x-requested-with: XMLHttpRequest user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36 content-type: application/x-www-form-urlencoded; charset=UTF-8 referer: http://localhost:3000/wx/weixin/customMenu accept-encoding: gzip, deflate, br accept-language: zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7,en-US;q=0.6 cookie: JSESSIONID=5FFCF1947C09102D5637E250ACD4AC3D connection: close content-length: 127 Accept-Charset: utf-8 Host: localhost:5060
{"name":"2323sdfsd","type":"2","content":"","imageMediaId":"","newsMediaId":"","url":"3434","id":"1","mediaId":"","msgType":""}
why does form submit become json? Is my configuration wrong?
This looks like body parsers were applied to proxied requests. See: https://www.npmjs.com/package/express-http-proxy#middleware-mixing