Search posts, tags, users, and pages
cli.vuejs.org/config check this.. it should help you
HI, the documentation is not too detailed. Could you kindly explain me step by step the meaning of these lines of code?especially this part here:
'/api': { target: 'localhost/& changeOrigin: true, pathRewrite: { '^/api': '' } }
thanks.
All requests made to /api' from within your application will be forwarded to target: 'localhost:3000'
changeOrigin: true :: if you need to access a backend that is not on localhost or when you’re using some virtual proxies (such as configured with Apache2) on your backend set it to true.
"pathRewrite": { "^/api": " }, pathRewrite setting says that if the path matches ^/api (i.e. if it starts with /api') then rewrite that portion with the empty string (i.e. remove it from the path), so all the request to localhost/api will go to https://localhost:3000..
i think this can help
ALAO LAWAL ADECHINA thanks for the answer.
Tell me if I understand correctly:
1) '/api': { target: 'localhost:3000' ........ }
All requests made to /api' from within my vue application will be forwarded to target: 'localhost:3000'
So if I have my client (vue app) runs at localhost:8080 and there are requests that start with resource path /api, these requests will be proxied to the target address: localhost:3000
for example:
request localhost:8080/api will be proxied to localhost:3000/api
request localhost:8080/api/1 will be proxied to localhost:3000/api/1 and so on.
.........................................................................................................
2) pathRewrite: { '^/api': '' }
^/api is a regex.
pathRewrite matches /api path segment in the target address and replaces it (/api) with empty string
for example proxied request to localhost:3000/api/1 will become localhost:3000/1
all correct or are there errors?
Thanks