From 9625268e67e0abc49cc9538f51416d86c5569266 Mon Sep 17 00:00:00 2001 From: Yutaka Kurosaki Date: Sat, 29 Nov 2025 17:27:40 +0900 Subject: [PATCH] fix: Add Livewire config and custom 404 page for subdirectory support - Add config/livewire.php with app_url and asset_url settings - Add custom 404 error page with consistent design - Add error translations for all 8 languages For subdirectory deployment: 1. Set APP_URL to include subdirectory (e.g., https://example.com/kb) 2. Set ASSET_URL if using CDN 3. Clear config cache after deployment --- src/config/livewire.php | 114 +++++++++++++++++++++++ src/lang/de/messages.php | 8 ++ src/lang/en/messages.php | 8 ++ src/lang/es/messages.php | 8 ++ src/lang/fr/messages.php | 8 ++ src/lang/ja/messages.php | 8 ++ src/lang/ko/messages.php | 8 ++ src/lang/zh-CN/messages.php | 8 ++ src/lang/zh-TW/messages.php | 8 ++ src/resources/views/errors/404.blade.php | 31 ++++++ 10 files changed, 209 insertions(+) create mode 100644 src/config/livewire.php create mode 100644 src/resources/views/errors/404.blade.php diff --git a/src/config/livewire.php b/src/config/livewire.php new file mode 100644 index 0000000..24a0e92 --- /dev/null +++ b/src/config/livewire.php @@ -0,0 +1,114 @@ + env('ASSET_URL'), + + /* + |-------------------------------------------------------------------------- + | Livewire App URL + |-------------------------------------------------------------------------- + | + | This value should be used if livewire assets are served from CDN. + | Livewire will communicate with an app through this url. + | + | Examples: "https://my-app.com", "myurl.com/app". + | + */ + + 'app_url' => env('APP_URL'), + + /* + |-------------------------------------------------------------------------- + | Livewire Endpoint Middleware Group + |-------------------------------------------------------------------------- + | + | This value sets the middleware group that will be applied to the main + | Livewire "message" endpoint (the endpoint that gets hit everytime + | a Livewire component updates). It is set to "web" by default. + | + */ + + 'middleware_group' => 'web', + + /* + |-------------------------------------------------------------------------- + | Livewire Temporary File Uploads Endpoint Configuration + |-------------------------------------------------------------------------- + | + | Livewire handles file uploads by storing uploads in a temporary directory + | before the file is stored permanently. All file uploads are directed + | to a global endpoint for temporary storage. Here you may configure. + | + */ + + 'temporary_file_upload' => [ + 'disk' => null, + 'rules' => null, + 'directory' => null, + 'middleware' => null, + 'preview_mimes' => [ + 'png', 'gif', 'bmp', 'svg', 'wav', 'mp4', + 'mov', 'avi', 'wmv', 'mp3', 'm4a', + 'jpg', 'jpeg', 'mpga', 'webp', 'wma', + ], + 'max_upload_time' => 5, + 'cleanup' => true, + ], + + /* + |-------------------------------------------------------------------------- + | Render On Redirect + |-------------------------------------------------------------------------- + | + | This value determines if Livewire will render before it's redirected + | or not. Setting it to "false" will mean the render method is skipped + | when performing a redirect, potentially improving performances. + | + */ + + 'render_on_redirect' => false, + + /* + |-------------------------------------------------------------------------- + | Navigate (SPA mode) + |-------------------------------------------------------------------------- + | + | By default, Livewire uses the "replace" strategy for SPA navigation + | which can sometimes cause issues with subdirectory deployments. + | + */ + + 'navigate' => [ + 'show_progress_bar' => true, + 'progress_bar_color' => '#2299dd', + ], + + /* + |-------------------------------------------------------------------------- + | Inject Assets + |-------------------------------------------------------------------------- + | + | By default, Livewire automatically injects its JavaScript and styles + | into the and of your pages. If you want to disable + | this behavior and manually include assets, set this to false. + | + */ + + 'inject_assets' => true, + +]; + diff --git a/src/lang/de/messages.php b/src/lang/de/messages.php index bfba6cd..d131800 100644 --- a/src/lang/de/messages.php +++ b/src/lang/de/messages.php @@ -115,6 +115,14 @@ 'already_registered' => 'Bereits registriert?', ], + // Errors + 'errors' => [ + '404_title' => 'Seite nicht gefunden', + 'page_not_found' => 'Seite nicht gefunden', + 'page_not_found_description' => 'Die gesuchte Seite konnte nicht gefunden werden.', + 'back_to_home' => 'Zurück zur Startseite', + ], + // Profile 'profile' => [ 'title' => 'Profil', diff --git a/src/lang/en/messages.php b/src/lang/en/messages.php index bdc2da4..bef3a45 100644 --- a/src/lang/en/messages.php +++ b/src/lang/en/messages.php @@ -115,6 +115,14 @@ 'already_registered' => 'Already registered?', ], + // Errors + 'errors' => [ + '404_title' => 'Page Not Found', + 'page_not_found' => 'Page Not Found', + 'page_not_found_description' => 'The page you are looking for could not be found.', + 'back_to_home' => 'Back to Home', + ], + // Profile 'profile' => [ 'title' => 'Profile', diff --git a/src/lang/es/messages.php b/src/lang/es/messages.php index c79d3f7..b8cc8af 100644 --- a/src/lang/es/messages.php +++ b/src/lang/es/messages.php @@ -115,6 +115,14 @@ 'already_registered' => '¿Ya está registrado?', ], + // Errors + 'errors' => [ + '404_title' => 'Página no encontrada', + 'page_not_found' => 'Página no encontrada', + 'page_not_found_description' => 'No se pudo encontrar la página que está buscando.', + 'back_to_home' => 'Volver al inicio', + ], + // Profile 'profile' => [ 'title' => 'Perfil', diff --git a/src/lang/fr/messages.php b/src/lang/fr/messages.php index b0ff411..d973687 100644 --- a/src/lang/fr/messages.php +++ b/src/lang/fr/messages.php @@ -115,6 +115,14 @@ 'already_registered' => 'Déjà inscrit ?', ], + // Errors + 'errors' => [ + '404_title' => 'Page non trouvée', + 'page_not_found' => 'Page non trouvée', + 'page_not_found_description' => 'La page que vous recherchez est introuvable.', + 'back_to_home' => 'Retour à l\'accueil', + ], + // Profile 'profile' => [ 'title' => 'Profil', diff --git a/src/lang/ja/messages.php b/src/lang/ja/messages.php index f721fd1..87b42ee 100644 --- a/src/lang/ja/messages.php +++ b/src/lang/ja/messages.php @@ -115,6 +115,14 @@ 'already_registered' => '既にアカウントをお持ちですか?', ], + // Errors + 'errors' => [ + '404_title' => 'ページが見つかりません', + 'page_not_found' => 'ページが見つかりません', + 'page_not_found_description' => 'お探しのページは見つかりませんでした。', + 'back_to_home' => 'ホームに戻る', + ], + // Profile 'profile' => [ 'title' => 'プロフィール', diff --git a/src/lang/ko/messages.php b/src/lang/ko/messages.php index f2293c4..2713897 100644 --- a/src/lang/ko/messages.php +++ b/src/lang/ko/messages.php @@ -115,6 +115,14 @@ 'already_registered' => '이미 계정이 있으신가요?', ], + // Errors + 'errors' => [ + '404_title' => '페이지를 찾을 수 없습니다', + 'page_not_found' => '페이지를 찾을 수 없습니다', + 'page_not_found_description' => '찾고 계신 페이지를 찾을 수 없습니다.', + 'back_to_home' => '홈으로 돌아가기', + ], + // Profile 'profile' => [ 'title' => '프로필', diff --git a/src/lang/zh-CN/messages.php b/src/lang/zh-CN/messages.php index c8d74a8..f631670 100644 --- a/src/lang/zh-CN/messages.php +++ b/src/lang/zh-CN/messages.php @@ -115,6 +115,14 @@ 'already_registered' => '已有账号?', ], + // Errors + 'errors' => [ + '404_title' => '页面未找到', + 'page_not_found' => '页面未找到', + 'page_not_found_description' => '您要查找的页面不存在。', + 'back_to_home' => '返回首页', + ], + // Profile 'profile' => [ 'title' => '个人资料', diff --git a/src/lang/zh-TW/messages.php b/src/lang/zh-TW/messages.php index c3b5b24..3f72442 100644 --- a/src/lang/zh-TW/messages.php +++ b/src/lang/zh-TW/messages.php @@ -115,6 +115,14 @@ 'already_registered' => '已有帳號?', ], + // Errors + 'errors' => [ + '404_title' => '頁面未找到', + 'page_not_found' => '頁面未找到', + 'page_not_found_description' => '您要查找的頁面不存在。', + 'back_to_home' => '返回首頁', + ], + // Profile 'profile' => [ 'title' => '個人資料', diff --git a/src/resources/views/errors/404.blade.php b/src/resources/views/errors/404.blade.php new file mode 100644 index 0000000..0eb69f6 --- /dev/null +++ b/src/resources/views/errors/404.blade.php @@ -0,0 +1,31 @@ + + + + + + {{ __('messages.errors.404_title') }} - {{ config('app.name') }} + @vite(['resources/css/app.css', 'resources/js/app.js']) + + +
+
+

404

+

+ {{ __('messages.errors.page_not_found') }} +

+

+ {{ __('messages.errors.page_not_found_description') }} +

+ +
+
+ + +