Laravel-Tongue icon indicating copy to clipboard operation
Laravel-Tongue copied to clipboard

Other subdomains won't behave correctly

Open codrin-axinte opened this issue 3 years ago • 1 comments

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:

  • nova.domain.test
  • luxury.domain.test
  • fr.domain.test
  • en.domain.test

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.

  • nova.domain.test when accessed at the root path it will still show the original website.
  • luxury.domain.test when accessed at the root path it will show the correct website, but the other routes will be mapped using this domain. Example: If I have the following route under the root domain:
Route::get('contact', [ContactController::class, 'index'])->name('contact.index');

When used under the subdomain luxury.domain.test as

 {{ route('contact.index') }}

It will map to luxury.domain.test/contact instead of domain.test/contact. However, every route for nova still works fine once you reach the dashboard by manually typing nova.domain.test/dashboard or any other route.

codrin-axinte avatar Jun 11 '21 10:06 codrin-axinte

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

pmochine avatar Jun 13 '21 08:06 pmochine