Vue Cors
//in your vue.config.js
module.exports = {
devServer: {
proxy: {
"/api": {
target: "<API BASE URL>",
changeOrigin: true,
pathRewrite: {
"^/api": "",
},
},
},
},
}
//in store actions account.js
let corsAnywhere = "https://corsanywhere.herokuapp.com"
let options = {
url:
process.env.NODE_ENV === "production"
? `${corsAnywhere}/API BASE URL/END POINT`
: "/api/END POINT",
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
data: {},
}
axios(options).then(respnse => {}).catch(error => {})
Rukkiecodes