title: Laravel get route current domain in multiple domains route
body: <p>I want to prevent access to some of my app routes from other domain except listed. It success using below code:</p>
  <pre><code>$loginRoutes = function() {
  Route::get('/', 'HomeController@index')-&gt;name('home');
  };
  
  Route::domain('domain1.com')-&gt;group($loginRoutes);
  Route::domain('domain2.com')-&gt;group($loginRoutes);
  Route::domain('localhost')-&gt;group($loginRoutes);
  </code></pre>
  <p>But the problem is when I call <code>{{route('home')}}</code>, 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?</p>
  <p>My current solution:</p>
  <pre><code>if (isset($_SERVER[&quot;HTTP_HOST&quot;]) &amp;&amp; $_SERVER[&quot;HTTP_HOST&quot;] == &quot;domain1.com&quot;) {
  Route::domain('domain1.com')-&gt;group($loginRoutes);
  }elseif (isset($_SERVER[&quot;HTTP_HOST&quot;]) &amp;&amp; $_SERVER[&quot;HTTP_HOST&quot;] == &quot;domain2.com&quot;) {
  Route::domain('domain2.com')-&gt;group($loginRoutes);
  }
  </code></pre>
  <p>It's work but I think it's dirty. I have a lot of domains/subdomain and also the routes too.</p>
  <p>I need solution on route directly, because I have a lot of routes, if I update each controller it's will take a long time. Maybe edit route provider or laravel vendor code is also no problem.</p>