Skip to content

dev-server中的proxyTable如何配置才能正确转发ajax请求呢? #60

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

Closed
lmnsg opened this issue Mar 15, 2016 · 10 comments
Closed

Comments

@lmnsg
Copy link

lmnsg commented Mar 15, 2016

发现如何配置都不会被转发。

var proxyTable = {
  '/v4': 'http://121.41.108.245:8899/yuntujinfu-wap'
}
// proxy api requests
Object.keys(proxyTable).forEach(function (context) {
  var options = proxyTable[context];
  if (typeof options === 'string') {
    options = {target: options, changeOrigin: true}
  }
  app.use(proxyMiddleware(context, options))
})

module.exports = app.listen(4001, function (err) {
  if (err) {
    console.log(err)
    return
  }
  console.log('Listening at http://localhost:4001')
})

Update: 发现把app.use(proxy) 放在比较靠前的位置才会生效

@yyx990803
Copy link
Member

嗯,已经修正了,要把 proxy middleware 提到最前。

@geekpeng
Copy link

然而并没有什么用还是遇到了这个问题

@bigzhu
Copy link

bigzhu commented May 6, 2016

我也遇到了,现在还是转发不了。

@suifeng123
Copy link

执行post 和get 可以,再是执行delete和put时遇到点问题

@Maplesog
Copy link

这个问题怎么解决的,还是转发不了

@Pines-Cheng
Copy link

转发不了。

@WLyKan
Copy link

WLyKan commented May 5, 2017

是不是因为target配置问题
'/v4': 'http://121.41.108.245:8899/yuntujinfu-wap'
后面不需要/yuntujinfu-wap

@lmnsg
Copy link
Author

lmnsg commented May 5, 2017

@WLyKan /yuntujinfu-wap 是我们 tomcat 的 context,必须要的。

楼上为啥都转发不了呢。

@maicss
Copy link

maicss commented Aug 21, 2017

楼上你们看看这个插件的用法啊,小尤回答的问题是这个插件跟vue-cli结合的时候没写好的问题,具体配置和使用看这里https://github.com/chimurai/http-proxy-middleware

@chengheai
Copy link

请求地址 => target: 'http://183.192.191.12:1000',
单个请求接口 => return axios.post('/copyrightmanagementservice/systemConfig/add', params );
请问我在config/index.js 怎么配置proxyTable ,谢谢!
@yyx990803 @lmnsg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants