diegslapasteque
diegslapasteque
FFilament
Created by trovster on 8/7/2023 in #❓┊help
Using domain causes CORS issues
Hello everyone 👋 I faced the same issue, and I found a solution to serve assets using the new domain if you're interested in : 1 - Create a new FILAMENT_ASSET_URL=https://admin.example.com in your .env. 2 - Add a new configuration value in config/filament.php :
'asset_url' => env('FILAMENT_ASSET_URL')
'asset_url' => env('FILAMENT_ASSET_URL')
3 - Add this code at the beginning of AdminPanelProvider to replace the asset url at runtime :
if (config('filament.asset_url')) {
config(['app.asset_url' => config('filament.asset_url')]);
}
if (config('filament.asset_url')) {
config(['app.asset_url' => config('filament.asset_url')]);
}
It's not mandatory to create a dedicated environment variable like I did, but I prefer to do it to keep the same behavior than laravel that also have a dedicated ASSET_URL variable. Moreover, if the assets are stored on a CDN or something like that, it will be easy to change the FILAMENT_ASSET_URL too. Maybe I should create a PR to propose to add a new ->assetUrl() method in the Filament\Panel, or to directly change the app.asset_url when a ->domain() is called... Hope it will helps fi
46 replies