Merge pull request #18524 from ubc-cpsc/fix/subpath-livewire-prefix

Fix Livewire and Passport routes for subpath hosting
This commit is contained in:
snipe
2026-02-10 08:34:18 +00:00
committed by GitHub
2 changed files with 12 additions and 6 deletions

View File

@@ -21,12 +21,18 @@ class LivewireServiceProvider extends ServiceProvider
*/
public function boot(): void
{
Livewire::setUpdateRoute(function ($handle) {
return Route::post('/' . config('livewire.url_prefix') . '/livewire/update', $handle);
$prefix = trim((string) config('livewire.url_prefix', ''), '/');
if ($prefix === '') {
$prefix = trim((string) parse_url(config('app.url'), PHP_URL_PATH), '/');
}
$prefix = $prefix === '' ? '' : '/' . $prefix;
Livewire::setUpdateRoute(function ($handle) use ($prefix) {
return Route::post($prefix . '/livewire/update', $handle);
});
Livewire::setScriptRoute(function ($handle) {
return Route::get('/' . config('livewire.url_prefix') . '/livewire/livewire.js', $handle);
Livewire::setScriptRoute(function ($handle) use ($prefix) {
return Route::get($prefix . '/livewire/livewire.js', $handle);
});
}
}

View File

@@ -64,7 +64,7 @@
<div class="buttons">
<!-- Authorize Button -->
<form method="post" action="/oauth/authorize">
<form method="post" action="{{ url('/oauth/authorize') }}">
{{ csrf_field() }}
<input type="hidden" name="state" value="{{ $request->state }}">
@@ -73,7 +73,7 @@
</form>
<!-- Cancel Button -->
<form method="post" action="/oauth/authorize">
<form method="post" action="{{ url('/oauth/authorize') }}">
{{ csrf_field() }}
{{ method_field('DELETE') }}