F
Filament4mo ago
pace

How to enforce ->viteTheme to use https?

I've created a custom theme using ->viteTheme method. However, when I apply the theme in the production environment, I encounter an issue where the asset imports are using HTTP instead of HTTPS, leading to mixed content errors. I came across a suggestion to use secure_assets, but it seems incompatible with ->viteTheme. This problem is specific to the Vite theme; other assets are correctly served over HTTPS when I use the following configuration:
if (env('APP_ENV') === 'production' || env('APP_ENV') === 'staging') {
$this->app['request']->server->set('HTTPS', true);
}
if (env('APP_ENV') === 'production' || env('APP_ENV') === 'staging') {
$this->app['request']->server->set('HTTPS', true);
}
Despite this, the assets from the Vite theme continue to be imported via HTTP. How can I ensure that Vite theme assets are served over HTTPS in a production environment?
No description
6 Replies
awcodes
awcodes4mo ago
Make sure APP_URL in your env has https Or force the schema in a service provider.
pace
paceOP4mo ago
My APP_URL: https://hml.s..... and my AppServiceProvider:
public function boot(): void
{
if (env('APP_ENV') === 'production' || env('APP_ENV') === 'staging'){
$this->app['request']->server->set('HTTPS', true);
}
}
public function boot(): void
{
if (env('APP_ENV') === 'production' || env('APP_ENV') === 'staging'){
$this->app['request']->server->set('HTTPS', true);
}
}
and my APP_ENV=production
Dennis Koch
Dennis Koch4mo ago
Do you have an asset URL set?
pace
paceOP4mo ago
There isn't, should there be? I will try thanks
LeandroFerreira
LeandroFerreira4mo ago
URL::forceScheme('https') you can also try ASSET_URL='https://xx' in the .env file
pace
paceOP4mo ago
worked for me thanks
Want results from more Discord servers?
Add your server