I wanted to prevent access to some of my app routes from other domain except listed. It success using below code:
$loginRoutes = function() {
Route::get('/', 'HomeController@index')->name('home');
};
Route::domain('domain1.com')->group($loginRoutes);
Route::domain('domain2.com')->group($loginRoutes);
Route::domain('localhost')->group($loginRoutes);
But the problem is when I call {{route('home')}}
, the URL always becomes the domain at the last line of the routes.php(at above case is http://localhost ). How to make it to current domain?
I use laravel 5.7 in php 7.3.3