-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
this.proxy 'content-type'修改 #13
Comments
|
现在遇到一个很奇怪的问题。 但到java服务器端,content-type 仍然是 "application/x-www-form-urlencoded" 我用postman测试后端接口时,就不会出现这种问题?? |
先不管重设content-type的方案,修改下你的ajax,直接发送一个application/json的请求,然后直接proxy到后端试试? |
我通过 ajax的post方法, 设定 contentType:"application/json" 后 url设置为java后台请求地址时,结果正确。 但,如果使用 proxy 后,再到java后台,结果仍然不正确。 |
貌似找到原因了。 在 co-proxy.js 中: function requestWap(param, options, callback) { form: param.ctx.request.body 把这个参数去掉,在java后台就正确了 |
let opt = Object.assign({ 把 form: param.ctx.request.body 修改为 body: param.ctx.request.body后就可以了。 |
赞!我升级下,跑下测试看看! |
我试了一下,如果直接把body注入到request的boay参数里,如果这个请求是一个Stream就会出问题; 这里是这样:如果当前请求content-type是application/json,则服务器收到的肯定是application/json;这里不建议再做什么转换 |
在执行this.proxy 前,修改 content-type 为 application/json 呢
The text was updated successfully, but these errors were encountered: