You're running into CORS problems.
https://github.com/barryvdh/laravel-cors
Have the other side send the correct headers so your app is allowed to POST to their server, by default that stuff is turned off for obvious reasons these days.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I need assistance or help for this issue, been searching from 4 days but could not figure it out. I have created API's in laravel and i am using Passport for Authentication. I am consuming the API's from different domain (react with fetch API).
All the GET requests are working , by giving 200 ok code, but when i make a post request to log the user in i get no response.
If i make login request from Post Man App , its working. Token is getting issued after login.
What's the issue?
Any help would be appreciated.
My fetch API POST request
let formData = new FormData();
formData.append('email', email);
formData.append('password', password);
fetch('http://localhost:8000/api/login', {
mode: 'no-cors',
body : formData,
// crossDomain: true,
//dataType: 'json',
method: 'POST',
headers: {
"Accept": "application/json",
"X-Requested-With" : 'XMLHttpRequest'
},
}
).then(response => {
if (response.ok) {
response.json()
.then(json => {
console.log(json);
});
}
});
if you remove the no-cors, you will see that, for every request, there is another extra OPTIONS request (which currently will fail, so the GET request wont even go out)
After you are at that point, you need to change the API code to accept requests coming from external domains, you do this by using CORS headers.
Install this package in your API: https://github.com/barryvdh/laravel-cors
That will make sure your server will respond with the correct headers, after you have done that (and have removed that mode: 'no-cors' from your js code) you should be getting 2 requests for every API call, first an OPTION request, and then the actual GET / POST request.
Please or to participate in this conversation.