Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

846
Visualizações
Laravel - Livewire, how to customize the global message URL?

Using a custom domain like the example below is not telling Livewire requests to be prefixed with the same subdomain subdomain1 in this example:

    Route::domain('subdomain1.'.env('APP_DOMAIN', 'localhost'))
             ->middleware(['web',.....])
             ->as('app.')
             ->group(base_path('routes/app.php'));

The problem is that the default callback for Livewire fetch endpoint which is /livewire/message/{message} is unfortunately using the root domain only and isn't based on where it has been called from. In my case from the subdomain1 and as you can guess this means a different storage of the session bag. It's a different session in the first place.

So storing in session for the sub-domain is not the same as storing in the session itself. Nevertheless, there are other customizations which I need in order to encapsulate Livewire usage based on each sub-domain, image I have a multi-tenancy based project and I need such segregation.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

After some googling and based on a solution in Livewire forums:

I tailored it to be suitable sub-domains usage

  • Step 1, added new route in routes/app.php:
use Livewire\Controllers\HttpConnectionHandler;

// .....
// Notice that this root route has to be the same as the one in step2:
Route::get('/', [AppController::class, 'index'])->name('app.index');
// .....

Route::post('livewire/message/{name}', [HttpConnectionHandler::class, '__invoke']);
  • Step2, In Blade just after @livewireScripts:
@livewireScripts
<script>
    window.livewire_app_url = '{{route('app.index')}}';
</script>

And in case you are wondering about the config of Livewire, there is no need to change it. Just leave it as it is; null:

'asset_url'  => null,
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda