2

I am creating React and Laravel website and below issue was shown in the console.

issue

cors.php

<?php

return [


    'paths' => ['api/*','login','register','admin/*','sanctum/csrf-cookie'],

    'allowed_methods' => ['GET', 'PUT', 'POST', 'DELETE', 'OPTIONS'],

    'allowed_origin' => ['http://localhost:3000'],

    'allowed_origins_patterns' => [],

    'allowed_headers' => [  
        
        'Content-Type', 
        'Authorization', 
        'Accept',
        'Accept-Language',
        'Content-Language',
        'Origin',
        'X-Requested-With',
        'X-XSRF-TOKEN',
        
        //'X-CSRF-TOKEN',
        'Access-Control-Request-Methods',
        'Access-Control-Request-Headers'
        
        ],

    'exposed_headers' => [
       // 'Access-Token',
       // 'Uid',
        'Authorization', 
        'X-CSRF-TOKEN'
        
    ],

    'max_age' => 0,

    'supports_credentials' => true,

];

What is the issue of my cors.php and what are valid and invalid headers which I put?

Nirodha Lakmali
  • 105
  • 1
  • 1
  • 10
  • 1
    Does this answer your question? [CORS Issue with React app and Laravel API](https://stackoverflow.com/questions/56158474/cors-issue-with-react-app-and-laravel-api) – miken32 Dec 28 '21 at 17:14

2 Answers2

-1

have you confirmed the frontend origin is "http://localhost:3000" as you allowed in cors.php only this

-1

add allowed-origin to * in your code.

Anand
  • 105
  • 3
  • 12