Answer the question
In order to leave comments, you need to log in
How to use Nuxt proxy for all axios requests?
hosted on heroku on different front and back domains.
making requests for backing blocks cors. I connected a proxy for nuxt,
but I just can’t figure out how it works.
i need any axios request to be redirected to the api domain....
so far my nuxt.config.js looks like this
modules: [
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/auth',
'@nuxtjs/axios',
'@nuxtjs/pwa',
'@nuxtjs/proxy'
],
axios: {
proxy: true,
proxyHeaders:false,
},
proxy: {
'/api': {
target: 'https://api-for-blog.herokuapp.com/api',
changeOrigin: false,
pathRewrite: {
'^/api' : '/'
}
}
},
// axios: {
// proxy: true
// },
//
// proxy: {
// '/api/': { target: 'https://api-for-blog.herokuapp.com/api', pathRewrite: {'^/api/': ''},changeOrigin: true }
// },
auth: {
strategies: {
local: {
endpoints: {
login: { url: "api/login", method: "post", propertyName: "meta.token" },
user: { url: "api/user", method: "get", propertyName: "data" },
logout: { url: api/logout", method: "post" },
},
}
},
watchLoggedIn: true,
rewriteRedirects: true
},
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