MAKE SURE SERVER IS RUNNING!!

Try it!  http://127.0.0.1:8000

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://secured.example.com/api/login (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 204.

Quick Check Cors.php Configs:

'paths' => ['*'], // NOT FOR PRODUCTION
...
'supports_credentials' => true,

Are you seeing this error for your Laravel API? If so, its very simple to enable.

Possible Solutions:

  1. Check the endpoints: for example: make sure the front end is matching the api.php routes: localhost/api/login vs localhost/login are not the same
  2. Endpoints - Check the endpoints exists in your api.php routes
  3. https with https is not allowed unless its the same domain (i think)
  4. The server is not running or unreachable. Try accessing the URL endpoint directly from the browser
  5. Edit Config > cors.php - See steps below for cors.php
  6. Check both frontend and backend match https or http
  7. There might be an error in the code. Check the PHP Error Logs

For my example, I was running a react application with HTTPS from a localhost to test my app and i kept getting cross origin CORS errors, this is how I fixed it.

To Allow laravel cross domain access to your API follow these steps:

1. Open file: Config > cors.php

Add your host in 'allowed_origins' - for example: https://127.0.0.1:3000

'allowed_origins' => ['https://127.0.0.1:3000'],

2zKoS8GsKK8