Try it!

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at (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:

'allowed_origins' => [''],