[Vuejs]-JS fetch + php codeigniter4 CORS issue

-2👍

It’s solved .As the Bros mentioned in replies (A preflight request issue)
Just adding this checking Request Code in (Routes.php) And The problem is solved

if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
  if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']) &&
       $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'] == 'GET')  {
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Headers:Role,Origin , Content-Type');
  }
  exit;
}

Thank U Guys

Leave a comment