Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

同时使用bodyParser.json()和bodyParser.urlencode()结果post请求得到504错误

$
0
0

写一个本地post请求发数据到本地服务器,然后通过本地服务器post到远程服务器http://www.imooc.com/data/check_f.php,然后发现一直报错504,检查了很久,发现我把bodyParser.json()或者bodyParser.urlencode()的其中一种注释掉都可以获取到数据(我之前是两种方式都存在的)。 不明白,这两种解析同时全局写为什么会有干扰? 屏幕快照 2018-01-13 下午11.25.38.png

屏幕快照 2018-01-13 下午11.26.03.png

客户端: $.post(“http://localhost:3000/data/check_f.php”, { num: $("#inputNumber").val() }, function (data) { $("#infoList").append("<li>你输入的数字 <b>" + $("#inputNumber").val() + “</b>是<b>” + data + “</b></li>”); }) 本地服务器端用代理(同时请求体原先用上面两种方式解析): var proxy = require(‘http-proxy-middleware’); var dataProxy = proxy(’/data’, { target: “http://www.imooc.com/”, changeOrigin: true }); app.use(’/data/*’, dataProxy);

为什么会有冲突呢?


Viewing all articles
Browse latest Browse all 14821

Trending Articles