I am trying to develop an app in Laravel 5.7 that works with 4 subdomains and 2 databases in this way:
Route::domain('www.example.com.br', function($route) {
Route::get('/', function() {
#single route to the app welcome page
})->name('welcome');
});
Route::domain('app.example.com.br', function($route) {
# connects with database "A"
...
# app routes
...
});
Route::domain('dev.example.com.br', function($route) {
# connects with database "B"
...
# app routes
...
});
Route::domain('sandbox.example.com.br', function($route) {
# connects with database "B"
...
# app routes
...
});
The "app routes" are the same for the 3 enviroments (app, dev, sandbox).
If a user log in "app.example.com.br" and manually change for "dev.example.com.br", for example, the database changes and must lose the session.
And don't matter which enviroment(app, dev, or sandbox), all app routes must stay in this enviroment, in other words, the app cannot change the initial enviroment acessed by the user.
My problem is exactly this: I access "app.example.com.br" and do the login, the authentication works, but for same reason, I am redirected to "sandbox.example.com.br". I cannot stay in "app.example.com.br".