Reputation: 199
As defined in documentation of barryvdh/laravel-cors, I've tried to implement laravel-cors on a fresh installation of Laravel but that doesn't work.
It yet gives the error of No Access Origin.
I'm trying to access the post request using Axios on Quasar
Any assistance will be thanked.
Specs:
Laravel-Cors documentation ref.
Works on Chrome if the extension of CORS is installed and enabled, but not the case without any extension in Firefox.
Hence need to make it work without any extension on all browsers.
Upvotes: 0
Views: 639
Reputation: 69
Also when you need to fetch post request from one url to another is it's necessary
to set mode: cors'
fetch('http://example.com/movies.json',{
method: 'post',
mode: 'cors',
credentials: 'include',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
})
.then((response) => {
return response.json();
})
.then((myJson) => {
console.log(myJson);
});
Upvotes: 0
Reputation: 997
you can use barryvdh/laravel-cors
to allow cors
or
just add this line
header("Access-Control-Allow-Origin: *");
in the top
of controller
which will receive requests
and axios data will not just a JSON
you should pass it as URL search parameter using URLSearchParams
object
example:
const params = new URLSearchParams();
params.append('email', email_variable);
params.append('password', password_variable);
axios.post('url_here', params)
.then();
Upvotes: 1