gecche / laravel-multidomain

A Laravel extension for using a laravel application on a multi domain setting
MIT License
838 stars 105 forks source link

Use $_SERVER['HTTP_HOST'] instead of $_SERVER['SERVER_NAME'] to detect Web Domain #77

Closed sardoj closed 2 years ago

sardoj commented 2 years ago

When you configure several domains on Laravel Forge (1 primary domain and several aliases), the package always detect the primary domain.

An easy solution is to update src/Foundation/DomainDetector.php (line 59) as following:

Replace return Arr::get($_SERVER,'SERVER_NAME');

By return Arr::get($_SERVER,'HTTP_HOST');

gecche commented 2 years ago

Hi,

the HTTP_HOST variable has some disadvantages with respect to SERVER_NAME as pointed out for example in #41.

However, if you follow the docs, you can customize the detection of the domain passing a closure to the application, as described here.

Cheers

Giacomo