Skip to content

Tenant routes don't work with cached routes.  #872

Open
@pxpm

Description

@pxpm

Description

Setting up a tenant APP with fallback domain.

My regular routes:

Route::group([
    'middleware' => ['web'],
    'domain' => config('tenancy.hostname.default'),

], function () {
       Route::get('teste1', 'TestController@index');
       Route::get('teste2', 'TestController@index');

});

My tenant routes:

Route::group([
    'middleware' => ['web'],
], function () {
       Route::get('tenantTest', 'Tenants/TestController@index');
});

Relevant config:

Eager and auto identification is on. Global override is false (it could be true as i am using global routes for specific domain).

Actual behavior

Getting 404 on tenant tenantTest route. I went to 404 page and: dd(app(\Hyn\Tenancy\Environment::class)->tenant());

Returned my actual tenant!!!!! I was about to go crazy. Changed configs, re-installed the package etc etc etc. php artisan route:clear did the trick. All routes are working.

Expected behavior

My main domain routes are HUGE really, and they probably should be cached. But if I cache them I can no longer access tenant routes because they are inserted 'on-the-fly' and not if routesAreCached!

Maybe one way of dealing with this is checking if if ($this->app->routesAreCached()) { if they are tenancy should de-serialize them, add tenant routes and re-serialize ? Don't even know if that is possible, just wondering.

Best,
Pedro

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions