I make a website with Vue3 and Laravel 8. I try to use axios to post data from vue to laravel and i allways got CORS error. I tried everything and nothing work. You can check the error here
Add header to axios
addUser() {
axios
.post("http://localhost:8000/api/user/store", this.user, {
headers: { "Access-Control-Allow-Origin": "*" }
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
})
.finally(() => (this.loading = false));
},
Add proxy to package.json
"proxy": "http://127.0.0.1:8000",
And tried this: https://enable-cors.org/server_apache.html
What can i do?
Try adding
axios.defaults.withCredentials = true;
to bootstrap.js