0👍
✅
So you are configuring Vue CLI dev-server (running on port 8001) to proxy all requests to /api
to http://localhost:8080/blog/api
(server) but at the same time configure Axios to use baseURL: process.env.VUE_APP_API_ADDRESS
…which means Axios is sending all requests directly to your server instead of proxy…
Just remove that baseURL: process.env.VUE_APP_API_ADDRESS
from Axios config
I also believe your pathRewrite
option in proxy config is incorrect.
- You dispatch request to
/dev-api/blog/lastBlogs
- Request goes to Vue dev-server (
localhost:8001
) - Proxy translates
/dev-api
intohttp://localhost:8080/blog/dev-api
=http://localhost:8080/blog/dev-api/blog/lastBlogs
pathRewrite
is applied to whole path part of the URL –/blog/dev-api/blog/lastBlogs
– RegEx^/dev-api
will not match
Try to change pathRewrite
into [process.env.VUE_APP_BASE_API]: '/api'
Source:stackexchange.com