Skip to content

Commit

Permalink
fix proxy when proxy api response had access-control-allow-origin
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangfx committed Nov 6, 2017
1 parent 43fa80f commit 7880cf6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion server/app/controller/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = app => {
const result = yield this.ctx.curl(url, opts)
this.ctx.status = result.status
delete result.headers['content-encoding'] // 设置了gzip encoding的话,转发请求将会出错,先取消此请求头的返回
this.ctx.set(result.headers)
delete result.headers['access-control-allow-origin'] // 开发环境不一定在api服务端这个允许头内,故将其删除,防止代理失败
this.ctx.body = result.data
}
* handleProxy (api) { // 如果url中带有_mockProxyStatus此参数,则开启代理转发
Expand Down

0 comments on commit 7880cf6

Please sign in to comment.