- In Chrome, press F12 to bring up
Developer tools - Click on
Networktab - Check
Preserve log - Check
Disable Cache - Press the
Clearbutton - Load the problematic https://mydomain.com/assets/fonts/
- Click on the first URL that appears in the
Developer tools - Under
Headers, expandResponse Headers, copy everything and paste them here
CORS error because of different origins
When I test my uploaded website, built with Laravel 5.8, without www (https://mydomain.com), it is working fine. But I get CORS error for resources when adding www to urls (https://www.mydomain.com):
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://mydomain.com/assets/fonts/ ...
I tried installing https://github.com/fruitcake/laravel-cors and using this configuration:
.env file is:
APP_URL="https://mydomain.com"
ASSET_URL="https://mydomain.com/assets"
published cors.php file is:
'paths' => ['*'],
'allowed_methods' => ['*'],
'allowed_origins' => ['https://www.mydomain.com/*', 'https://mydomain.com/*', 'http://www.mydomain.com/*', 'http://mydomain.com/*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => false,
and in Kernel.php I have added the middleware at the top:
protected $middleware = [
HandleCors::class, // keep this here
...
];
I still cannot get both origins considered the same.
For assets use .htaccess in public
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
Please or to participate in this conversation.