I have a VUE application configured with a net.core application as backend
To avoid cors problems, it would be ideal to configure a proxy. However my attempts were in vain, since I did not find a way to do it.
The application is created with the CLI 3 of vue, and uses typescript.
Try adding the following lines to the package.json file, but the proxy still does not work, that is, all calls are still made to the outgoing server:
"proxyTable": {
"/api":{
"target": "http://localhost:5000",
"changeOrigin": true,
"pathRewrite": {
"^/api": ""
}
}
},
"proxy": {
"/api":"http://localhost:5000"
}
None of these things moved the call to that port.
The calls are axios, such as:
Axios.post(process.env.VUE_APP_BASE_URI + 'me', { }, {withCredentials: true})
where the constant is defined as:
VUE_APP_BASE_URI=api/
The constant looks and works. Without the constant, the error occurs the same.
Is there a problem in how I have written the proxy or am I making some other error?
my package.json:
{
"name": "xxxxxx",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"proxyTable": {
"/api":{
"target": "http://localhost:5000",
"changeOrigin": true,
"pathRewrite": {
"^/api": ""
}
}
},
"dependencies": {
"axios": "^0.18.0",
"bootstrap-vue": "^2.0.0-rc.11",
"font-awesome": "^4.7.0",
"register-service-worker": "^1.0.0",
"vue": "^2.5.17",
"vue-class-component": "^6.0.0",
"vue-property-decorator": "^7.0.0",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.0.0",
"@vue/cli-plugin-pwa": "^3.0.0",
"@vue/cli-plugin-typescript": "^3.0.0",
"@vue/cli-service": "^3.0.0",
"typescript": "^3.0.0",
"vue-template-compiler": "^2.5.17"
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
One of the attempts was the one recommended by this page . and the same thing