Support the ongoing development of Laravel.io →
Requests Input
Last updated 2 years ago.
0

So FYI somehow I was able to fix the issue by adding the latter two lines to index.php in Laravel:

header("Access-Control-Allow-Origin: *");
header('Access-Control-Request-Headers: Content-Type');
header('Access-Control-Allow-Headers: Origin, Content-Type');

On the ReactJS side, I explicitly defined the 'Content-Type' of the request to 'application/json' but I'm not sure if that part is really necessary.

Note that even though I have added those headers to index.php, the AJAX requests look like they are going to do an 'OPTIONS' handshake before the actual payload request + response.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

kylanhurt kylanhurt Joined 11 Mar 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.