I have my routes set up as follows:
\'{username}.u.\'.env(\'APP_DOMAIN\'),
], function () {
Route::get(\'/\', \
This has been answered, at least partially, by myself here: Creating a route in Laravel using subdomain and domain wildcards
In short, you cannot make the whole domain a parameter in the routes file. Instead, you assign a middleware that will check the current domain, match it against your pre-defined list of allowed user domains and based on that - take some decision (eg. what method to hit in your controller).
Consider:
Route::group([
'middleware' => 'domain-check',
], function () {
Route::get('/', 'FrontendController@handle');
});
And then in your FrontendController:
public function handle(Request $request)
{
// Information about the current user/domain is here
$request->client;
// An example - let's imagine that client object contains a view ID
return response()->view($request->client->view);
}