DEV Community

Kamau Wanyee
Kamau Wanyee

Posted on

TenancyForLaravel FileSystem Bootstrapper asset Gotcha

TLDR; If you are using the FileSystemBootstrapper on the archtechx/tenancy package and also the Laravel-Vite package, update your tenancy config (tenancy.filesystem.asset_helper_tenancy) to false. Otherwise your generated script/style tags after building assets will be returning a tenant-scoped asset URL.

Here is the context of the problem I was facing:

I am building a multi-tenant SaaS application using this tenancy package from Tenacy for Laravel. It has a concept of tenancy bootstrappers that modifies relevant framework defaults to make the application tenant aware. The FileSystem Bootstrapper makes the Laravel asset() helper method return tenant specific assets through a TenantAssetController.
I also replaced Laravel Mix with Vite and I'm using this Laravel Vite package to make the integration easier. The package provides @vite directive to output all the necessary asset tags in your blade file. The underlying methods use the asset() helper method from the framework. Therefore, any generated asset URL is tenant-scope if I am under a tenant aware route. I am using VueJS for templating so my page ends up not being rendered correctly.

The solution is to update a tenancy config (tenancy.filesystem.asset_tenancy_helper) to false. The asset() helper revert to default. The tenancy package still provides tenant_asset() helper method for tenant specific assets.

I hope this helps someone out there facing the same issue and save you time.

Top comments (2)

Collapse
 
harryhuddle profile image
Harry Potts

Thanks Kamau, certainly helped me get the fix for this quickly, was scratching my head for a moment there.

Collapse
 
steekam profile image
Kamau Wanyee

I spent hours scratching my head so others won't have to :)