pmochine / Laravel-Tongue

🎉 Finally a subdomain localization that works how you want it to work. 🌐
MIT License
40 stars 7 forks source link

Other subdomains won't behave correctly #38

Open codrin-axinte opened 3 years ago

codrin-axinte commented 3 years ago

Introduction

The issue is when you have other subdomains such as nova.domain.test, the root path will still show the original website and not changing to the Nova Admin panel. The second case is when the subdomain, in my case luxury.domain.test, it loads the other layout but the routes won't map correctly. Let me be more clear.

Setup

I have the following subdomains:

The .env values are the following:

APP_DOMAIN=domain.test
SESSION_DOMAIN=.domain.test
// config/localization.php
[ 
 'subdomains' => [
        'nova',
        'luxury',
    ],
]

The routes within the luxury package are wrapped in this way:

Route::middleware('web')->domain('luxury.' . env('APP_DOMAIN') )->group(function(){
     // routes...
});

and for nova, I have set the following values in the config:

// config/nova.php
[
    'path' => '/',
]

and .env file

NOVA_DOMAIN_NAME=nova.domain.test

Describing Issue

Now, I have two scenarios.

If I wrap my default routes within the web.php like this

Route::domain(env('APP_DOMAIN'))->group(function(){
  // routes...
});

everything works fine but not the translated routes. When trying to access a translated subdomain it gives a 'route is null' or not defined.

However, in the second scenario if I remove the above code, the translated subdomains are working as intended, but the other two subdomains are behaving differently.

pmochine commented 3 years ago

Thanks for the issue! When I find the time, I'm going to check the issue!