79409911

Date: 2025-02-03 20:20:14
Score: 0.5
Natty:
Report link

Did you check your cors.php file? It's in config directory of your project.

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Cross-Origin Resource Sharing (CORS) Configuration
    |--------------------------------------------------------------------------
    |
    | Here you may configure your settings for cross-origin resource sharing
    | or "CORS". This determines what cross-origin operations may execute
    | in web browsers. You are free to adjust these settings as needed.
    |
    | To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
    |
    */

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

    'allowed_methods' => ['*'],  // Allows all HTTP methods

    'allowed_origins' => ['http://localhost:5173'],  // Allows requests from your front-end origin or set * for testing

    'allowed_origins_patterns' => [],  // No specific patterns

    'allowed_headers' => ['*'],  // Allows all headers

    'exposed_headers' => [],  // No specific headers exposed

    'max_age' => 0,  // No maximum age for preflight requests

    'supports_credentials' => false,  // Whether credentials are supported
];

and remove fruitcake/laravel-cors

and try php artisan optimize:clear

make sure your API routes prefix is in 'paths' => ['api/*', 'sanctum/csrf-cookie']

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): Did you
  • Low reputation (1):
Posted by: Mohammad Salehnia