Multi-domains, custom theme and CSP
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- ИванМаксимов
- Posts: 8
- Joined: 06 Sep 2023, 17:16
Multi-domains, custom theme and CSP
Hello!
ENV:
- laravel-aimeos 2023.07.01
- custom domains configuration
- installed one custom theme (named 't1')
- have 2 domains: shop.local and aimeos.local
- APP_URL=http://shop.local
- APP_DEBUG=false
- domain aimeos.local have default theme
- domain shop.local have t1 theme
Trouble:
On the site aimeos.local, the html header includes css/js files from the theme "t1" in an absolute path with the site name "shop.local" despite the fact that the theme for it is set to 'default' and CSP blocks load these files
File vendor/aimeos/aimeos-laravel/views/base.blade.php - is default file from installation just added comment around @yield('aimeos_header'):
After change theme i also run artisan aimeos:clear, view:clear, optimize commands but theme still unchanged - t1.
What else needs to be done for the theme change to take effect?
ENV:
- laravel-aimeos 2023.07.01
- custom domains configuration
- installed one custom theme (named 't1')
- have 2 domains: shop.local and aimeos.local
- APP_URL=http://shop.local
- APP_DEBUG=false
- domain aimeos.local have default theme
- domain shop.local have t1 theme
Trouble:
On the site aimeos.local, the html header includes css/js files from the theme "t1" in an absolute path with the site name "shop.local" despite the fact that the theme for it is set to 'default' and CSP blocks load these files
File vendor/aimeos/aimeos-laravel/views/base.blade.php - is default file from installation just added comment around @yield('aimeos_header'):
Code: Select all
<!-- default theme begin aimeos_header -->
@yield('aimeos_header')
<!-- default theme end aimeos_header -->
After change theme i also run artisan aimeos:clear, view:clear, optimize commands but theme still unchanged - t1.
What else needs to be done for the theme change to take effect?
- Attachments
-
- Снимок экрана 2023-09-15 в 13.04.37.jpg (140.27 KiB) Viewed 20205 times
-
- Снимок экрана 2023-09-15 в 13.04.17.jpg (210.27 KiB) Viewed 20205 times
-
- Снимок экрана 2023-09-15 в 11.36.56.png (177.59 KiB) Viewed 20205 times
Last edited by ИванМаксимов on 15 Sep 2023, 10:37, edited 1 time in total.
- ИванМаксимов
- Posts: 8
- Joined: 06 Sep 2023, 17:16
Re: Multi-domains, custom theme and CSP
I found where generates url to css files:
vendor/aimeos/aimeos-base/src/View/Helper/Content/Standard.php:68
\Aimeos\Base\View\Helper\Content\Standard::baseurl
Here code:
But $this->view()->config() gets static value from cached config file instead get asset() dynamic value based on Request
vendor/aimeos/aimeos-base/src/View/Helper/Content/Standard.php:68
\Aimeos\Base\View\Helper\Content\Standard::baseurl
Here code:
Code: Select all
{
if( !isset( $this->baseurls[$fsname] ) ) {
$this->baseurls[$fsname] = rtrim( $this->view()->config( 'resource/' . $fsname . '/baseurl', '' ), '/' );
}
return $this->baseurls[$fsname];
}
Code: Select all
'fs-theme' => [
'adapter' => 'Standard',
'tempdir' => storage_path ( 'tmp' ),
'basedir' => public_path ( 'vendor/shop/themes' ),
'baseurl' => rtrim ( env ( 'ASSET_URL', PHP_SAPI == 'cli' ? env ( 'APP_URL' ) : '' ), '/' ) . '/vendor/shop/themes',
],
Re: Multi-domains, custom theme and CSP
If you have multiple domains only use this as basedir value:ИванМаксимов wrote: ↑15 Sep 2023, 10:29Code: Select all
'fs-theme' => [ 'adapter' => 'Standard', 'tempdir' => storage_path ( 'tmp' ), 'basedir' => public_path ( 'vendor/shop/themes' ), 'baseurl' => rtrim ( env ( 'ASSET_URL', PHP_SAPI == 'cli' ? env ( 'APP_URL' ) : '' ), '/' ) . '/vendor/shop/themes', ],
Code: Select all
'baseurl' => '/vendor/shop/themes'
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
- ИванМаксимов
- Posts: 8
- Joined: 06 Sep 2023, 17:16
Re: Multi-domains, custom theme and CSP
Yes, it is work!
I think you need include this into your documentation ...
I think you need include this into your documentation ...
Re: Multi-domains, custom theme and CSP
The best option is to not set the ASSET_URL in your .env file like in the example that is shipped with Aimeos:
https://github.com/aimeos/aimeos/blob/m ... example#L7
We've added a tip in the section about adapting the routing:
https://aimeos.org/docs/latest/laravel/ ... he-routing
https://github.com/aimeos/aimeos/blob/m ... example#L7
We've added a tip in the section about adapting the routing:
https://aimeos.org/docs/latest/laravel/ ... he-routing
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star