CORS response not working in some routes in Laravel 11

Discussão em 'Angular' iniciado por Youssera Zoukha MECIFI, Novembro 14, 2024.

  1. im creating an application using Angular 16 for the frontend and Laravel 11 for the backend, everything worked well in my local project but after hosting it, some routes like add to cart / upload file is returning a cors error XHR in the console, for example when i hit add to cart i get an unexpected error occured and when i opened the console i see that the error cors appeared and there is no access-control-allow-origin is misssing in the network , altough the item was added to the cart , i dont understand why this problem is only in my hosted project and why is it only appearing for certain routes.

    And for my cors.php file here is my code :

    <?php

    return [


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

    'allowed_methods' => ['*'],

    'allowed_origins' => ['*'],

    'allowed_origins_patterns' => [],

    'allowed_headers' => ['*'],

    'exposed_headers' => [],

    'max_age' => 0,

    'supports_credentials' => false,


    ];

    does anyone have an idea what seems to be the probelem ? my domain names are like this :

    for the front => www.localhost:4200 / www.frontdemo.*******.com

    and the back => www.localhost:8000 / www.backdemo.*******.com

    Local and hosted project respectfully

    Continue reading...

Compartilhe esta Página