Answer the question
In order to leave comments, you need to log in
How to properly configure proxy in vue.config.js?
Good day.
The task is to pass a json file to vuejs via axios (it sends a response from mysql database), which is parsed through a php file (in my case, api.php).
<b>Код App.vue</b>
<script>
export default {
name: 'app',
data (){
return{
info: null,
members: [],
}
},
mounted: function(){
this.getM();
},
methods:{
getM: function(){
axios
.get('api.php')
.then(response => (this.members = response.data.members));
}
}
}
</script>
module.exports = {
devServer: {
proxy: 'http://localhost:80'
}
}
Answer the question
In order to leave comments, you need to log in
This setting will change the port for serve, not which port requests will go to. And port 80 is occupied by a web server, which means that serve will not start. You probably open the assembly on localhost and not on localhost:3000. Since the ports are different in your console in dev mode from port 3000, you should write about cors. Either resolve cors, hello headers and http protocol. Or set up the assembly in watch so that you can open it on localhost.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question