Skip to content

A free open source IT asset/license management system

Fix Livewire routes for subpath hosting

Joël Pittetb2728b4eb175
diff --git a/app/Providers/LivewireServiceProvider.php b/app/Providers/LivewireServiceProvider.php
index 9fd0fd561f..740a1e79b5 100644
--- a/app/Providers/LivewireServiceProvider.php
+++ b/app/Providers/LivewireServiceProvider.php
@@ -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);
});
}
}
diff --git a/resources/views/vendor/passport/authorize.blade.php b/resources/views/vendor/passport/authorize.blade.php
index cdf3285298..991c9b9804 100644
--- a/resources/views/vendor/passport/authorize.blade.php
+++ b/resources/views/vendor/passport/authorize.blade.php
@@ -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') }}