Answer the question
In order to leave comments, you need to log in
Why doesn't the proxy rule work in NuxtJS+Axios?
I'm trying to use a third party API in my NuxtJS project. There was a problem of cross-domain requests, as I understand it, you can use @nuxtjs/proxy to solve them.
I make a config according to the documentation:
require('dotenv').config();
export default {
mode: 'universal',
plugins: [],
buildModules: [],
modules: [
'@nuxtjs/axios',
'@nuxtjs/proxy',
['@nuxtjs/dotenv', { systemvars: true }],
],
axios: {
proxy: true,
},
proxy: {
'/api': {
target: "http://custom-service.com",
pathRewrite: {
'^/api' : ""
},
},
},
}
export default {
created() {
this.$axios.get("/api/places");
}
}
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