Than In the console I " /> Than In the console I " /> Than In the console I "/>

Laravel/Valet - has been blocked by CORS policy:

64 Views Asked by At

My laravel version: 8.2.15

I have these in one of my pages:

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

Than In the console I see these errors:

Access to script at 'https://code.jquery.com/jquery-3.6.0.min.js' from origin 'https://www.mydomain.test' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I am running this on MacOS with Valet.

In my config/cors.php I have added this:

<?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' => ['*'],

    'allowed_methods' => ['*'],

    'allowed_origins' => ['*.socket.*','*.jquery.*'],

    'allowed_origins_patterns' => [],

    'allowed_headers' => ['*'],

    'exposed_headers' => [],

    'max_age' => 0,

    'supports_credentials' => false,

];

But it does not seem to work. I have followed this guide: https://dev.to/keikesu0122/a-simple-way-to-enable-cors-on-laravel-55i and again it does not work.

How can I resolve this error ?

0

There are 0 best solutions below