fix(routes): implementing universal routes to resolve 404 on central domain
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Successful in 46s
Koori-ERP-Deploy-System / deploy-production (push) Has been skipped

This commit is contained in:
2026-01-15 13:36:59 +08:00
parent a6ed2720d5
commit 79e5916d19
4 changed files with 11 additions and 11 deletions

View File

@@ -14,7 +14,7 @@ use App\Http\Controllers\Landlord\TenantController;
|
*/
Route::prefix('landlord')->name('landlord.')->middleware(['web', 'auth'])->group(function () {
Route::prefix('landlord')->name('landlord.')->middleware(['web', 'auth', \Stancl\Tenancy\Middleware\PreventAccessFromTenantDomains::class])->group(function () {
// 房東儀表板
Route::get('/', [DashboardController::class, 'index'])->name('dashboard');

View File

@@ -11,16 +11,13 @@ use Stancl\Tenancy\Middleware\PreventAccessFromCentralDomains;
| Tenant Routes
|--------------------------------------------------------------------------
|
| 租戶專屬路由。當使用者透過租戶網域 ( koori.koori-erp.test) 存取時,
| 會自動初始化租戶 context 並連接到對應的租戶資料庫。
| 租戶專屬路由。當使用者透過租戶網域存取時,會自動初始化租戶 context。
|
| 注意:目前 ERP 路由定義在 routes/web.php這些路由在「所有」域名都可用。
| 當請求來自租戶域名時tenancy middleware 會自動切換到租戶資料庫。
|
*/
Route::middleware([
'web',
InitializeTenancyByDomain::class,
PreventAccessFromCentralDomains::class,
])->group(function () {
// 載入與 central 相同的 ERP 路由,但運行在租戶資料庫 context 中
require base_path('routes/web.php');
});
// 此處可以定義「僅」租戶可用的路由 (central domain 不可存取)
// 目前不需要,因為 ERP 功能對 central 和 tenant 都開放

View File

@@ -16,7 +16,9 @@ use App\Http\Controllers\TransferOrderController;
use App\Http\Controllers\UnitController;
use App\Http\Controllers\Admin\RoleController;
use App\Http\Controllers\Admin\UserController;
use Stancl\Tenancy\Middleware\InitializeTenancyByDomainOrSubdomain;
// 登入/登出路由
Route::get('/login', [LoginController::class, 'show'])->name('login');
Route::post('/login', [LoginController::class, 'store']);
Route::post('/logout', [LoginController::class, 'destroy'])->name('logout');