tenancy: Tenant could not be identified on domain tenancy
Describe the bug
I can’t access central domain. It says: “Tenant could not be identified on domain tenancy”.
Steps to reproduce
Installed fresh copy of Laravel. Installed Tenancy and configured according to the documentation. Created a custom Tenant model:
class Tenant extends BaseTenant implements TenantWithDatabase
{
use HasDatabase, HasDomains;
}
Changed some configuration in config/tanancy.php :
return [
'tenant_model' => \App\Tenant::class,
'id_generator' => null,
'domain_model' => Domain::class,
'central_domains' => [
'tenancy.uz',
],
...
]
I’m planning to use multiple databases and subdomains. My default Laravel route is not changed. There’s my tenancy route:
Route::middleware([
'web',
InitializeTenancyBySubdomain::class,
PreventAccessFromCentralDomains::class,
])->group(function () {
Route::get('/', function () {
return 'This is your multi-tenant application. The id of the current tenant is ' . tenant('id');
});
});
When I create tenants, their subdomains (foo.tenancy.uz, bar.tenancy.uz) work normal. But the central domain (tenancy.uz) is not accessible (not working).
More: https://flareapp.io/share/x5MkboPk
Expected behavior
Central domain should open my central app where users can sign up and create tenants.
Your setup
- Laravel version: 7
- stancl/tenancy version: 3
- Storage driver: mysql
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (6 by maintainers)
For those who still have the problem, make sure your central domain is without http/https at first. If you use
InitializeTenancyBySubdomain
middleware, make sure that thedomains
table does not contain the full domain. If you are using the entire domain then change the middleware toInitializeTenancyByDomain
Your
createTenant()
method doesn’t create a domain, so there’s no domain that the tenant can be identified on. Create a domain for the tenant and it should work 👍🏻i have same problem