You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Subresource Integrity: The resource 'https://cdn.example.com/vendor/horizon/styles.css' has an integrity attribute, but the resource requires the request to be CORS enabled to check the integrity, and it is not. The resource has been blocked because the integrity cannot be enforced.
Subresource Integrity: The resource 'https://cdn.example.com/vendor/horizon/styles-dark.css' has an integrity attribute, but the resource requires the request to be CORS enabled to check the integrity, and it is not. The resource has been blocked because the integrity cannot be enforced.
Description of the bug
The problem relies in that Horizon uses a new instance of \Illuminate\Foundation\Vite for injecting the CSS and javascript:
$viteDataSchemeLight = new ViteFoundation();
$viteDataSchemeLight->useHotFile($nonExistentFileName);
$viteDataSchemeLight->useStyleTagAttributes([
'data-scheme' => 'light',
]);
The problem, is that this generates a tag like this:
Horizon Version
v5.24.3
Laravel Version
11.x
PHP Version
8.3
Redis Driver
PhpRedis
Redis Version
Database Driver & Version
Description
Brief
If you configure your
ASSET_URL
: (https://laravel.com/docs/11.x/vite#custom-base-urls)Then the Horizon CSS won't load at all:
Chrome Dev Console:
Description of the bug
The problem relies in that Horizon uses a new instance of
\Illuminate\Foundation\Vite
for injecting the CSS and javascript:The problem, is that this generates a tag like this:
In order for the browser to check the data integrity and use the integrity tag:
Access-Control-Allow-Origin: *
). ✅crossorigin
attribute must be defined in the<link>
tag and set toanonymous
. ❌How To Fix
Simply add
'crossorigin' => 'anonymous'
to both tags:$viteDataSchemeDark = new ViteFoundation(); $viteDataSchemeDark->useHotFile($nonExistentFileName); $viteDataSchemeDark->useStyleTagAttributes([ 'data-scheme' => 'dark', + 'crossorigin' => 'anonymous', ]);
Steps To Reproduce
ASSET_URL
to point to a CDN:Ensure the CDN is sending the proper CORS headers.
The text was updated successfully, but these errors were encountered: