Multi-domains, custom theme and CSP

Help for integrating the Laravel package
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!
User avatar
ИванМаксимов
Posts: 8
Joined: 06 Sep 2023, 17:16

Multi-domains, custom theme and CSP

Post by ИванМаксимов » 15 Sep 2023, 10:18

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'):

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
Снимок экрана 2023-09-15 в 13.04.37.jpg (140.27 KiB) Viewed 20205 times
Снимок экрана 2023-09-15 в 13.04.17.jpg
Снимок экрана 2023-09-15 в 13.04.17.jpg (210.27 KiB) Viewed 20205 times
Снимок экрана 2023-09-15 в 11.36.56.png
Снимок экрана 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.

User avatar
ИванМаксимов
Posts: 8
Joined: 06 Sep 2023, 17:16

Re: Multi-domains, custom theme and CSP

Post by ИванМаксимов » 15 Sep 2023, 10:29

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:

Code: Select all

	{
		if( !isset( $this->baseurls[$fsname] ) ) {
			$this->baseurls[$fsname] = rtrim( $this->view()->config( 'resource/' . $fsname . '/baseurl', '' ), '/' );
		}

		return $this->baseurls[$fsname];
	}
But $this->view()->config() gets static value from cached config file instead get asset() dynamic value based on Request

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',
        ],

User avatar
aimeos
Administrator
Posts: 8238
Joined: 01 Jan 1970, 00:00

Re: Multi-domains, custom theme and CSP

Post by aimeos » 15 Sep 2023, 11:08

ИванМаксимов wrote: 15 Sep 2023, 10:29

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',
        ],
If you have multiple domains only use this as basedir value:

Code: Select all

'baseurl' => '/vendor/shop/themes'
Otherwise, the ASSET_URL or APP_URL values from your .env files are used and the values of these settings is only correct for one domain.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
ИванМаксимов
Posts: 8
Joined: 06 Sep 2023, 17:16

Re: Multi-domains, custom theme and CSP

Post by ИванМаксимов » 15 Sep 2023, 12:07

Yes, it is work!
I think you need include this into your documentation ...

User avatar
aimeos
Administrator
Posts: 8238
Joined: 01 Jan 1970, 00:00

Re: Multi-domains, custom theme and CSP

Post by aimeos » 15 Sep 2023, 12:54

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
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply