romegasoftware/Multitenancy

Making routes bypass the tenant middleware

Closed this issue · 1 comments

rvzug commented

Hi,
What is the best approach to bypass the tenant middlewares?

Available for tenants (backoffice) ==> tenant.auth
tenant.domain.com/
tenant.domain.com/dashboard
tenant.domain.com/products/add

Available for customers of tenants ==> tenant.guest
tenant.domain.com/form-to-some-guest-logic

Available for everyone without a scope/tenant middleware
domain.com/
domain.com/register (logic to let visitors create themself as tenant)

==> This doesn't workt at this moment. As soon as I define a Route::get('/', ...) all visitors, subdomain or not will return to the domain.com/ endpoint. And it should deffer based on when there is an tenant-subdomain or not.

How does your routes file look like? You should be able to bypass any tenant middleware by defining the route outside of the route group you apply the middleware on.

Route::middleware('tenant.auth')->group(function () {
    // all tenant auth routes
});


Route::middleware('tenant.guest')->group(function () {
    // all tenant guest routes
});

// all non tenant related routes
Route::get('/register', ...);