I am completely new to ReactJs and I am trying to learn it using Laravel and following a tutorial, but I am faced with the below error:
Request URL: http://localhost:8000/api/signup
Referrer Policy: strict-origin-when-cross-origin
I have tried these videos which shows how to solve the issue, but it doesn’t work for me, is there any other way or am I missing something?
Links are below:
2
Answers
I found the solution by doing two steps
1.I have added the below lines in .env file
php artisan serve
in bakend and runcd react
npm run dev
the below errors are solved as well as
On your Laravel project:
Check if cors.php file exists in config/cors.php location.
If the file does not exists please follow https://github.com/fruitcake/laravel-cors
On
'allowed_origins' => []
, add the base URL of the react application in the array. Make sure you add the URL of both production and development.Note: If your both application are running in
localhost
, then cors issue may not occur.