Hi to all,
i'm trying to configure proxyTable, and i have just copied the example in documentation:
proxyTable: {
// proxy all requests starting with /api to jsonplaceholder
'/api': {
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
},
After that, i have run npm run dev (i have added this on config/index.js).
When i try to use axios, the requests are sent to http://localhost:8080 and not to http://jsonplaceholder.typicode.com.
the request sent with axios is quite simple:
axios.get('/api/1') // Just for example
When i try to use axios, the requests are sent to http://localhost:8080 and not to http://jsonplaceholder.typicode.com.
Well, the request will of course be sent to localhost:8080, which will then send the request to http://jsonplaceholder.typicode.com - that's what proxys do.
I would also like to know this, because I moved from vue-resources to axios and proxyTable in webpack is not working anymore. Any suggestions?
I met the same issue. Now fixed with adding pathRewrite to proxyTable config, like
......,
pathRewrite:{
'^/api':""
}
I don't know why need this, but it's work for me .
I also met the same problem that proxyTable not working after replacing vue-resource with axios. Any ideas?
@isjia: The value is a RegEx. The ^ means "starts with".
I have used Vue proxyTable. And it's working in Firefox. But it's not working in chrome. It throws forbidden error. What is the problem?
My code:
'/api': {
target: '****',
changeOrigin: true,
pathRewrite: {
'^/api': '/api'
}
Hi, is anyway some solution to configure target proxy url in json file which is configurable without building everytime ? i.e external configuration like setting.json which populate the target proxy url ?
Most helpful comment
I would also like to know this, because I moved from vue-resources to axios and proxyTable in webpack is not working anymore. Any suggestions?