Answer the question
In order to leave comments, you need to log in
Why doesn't it remove the prefix from the url Axios + Proxy?
Nuxt project
in nuxt.config.js
axios: {
proxy: true,
debug: true,
browserBaseURL: '/api',
},
proxy: {
'/api': {
target: process.env.API_URL,
changeOrigin: true,
pathRewrite: {
'^/api': '',
},
},
},
$axios
.$get(`/v1/autocomplete`, {
params: {
address: inputSearch.value,
},
})
.then((response: any) => {
isAutocomplete.value = true
autocomplete.value = response.result
})
.catch((error: any) => {
console.log(error)
})
Request URL: http://127.0.0.1:3000/api/v1/autocomplete?address=asdasd
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question