Admin route not working in Twill 3.3 + Laravel 11

On fresh install of Laravel 10 everything works without any problem. On fresh install of Laravel 11 /admin route throws 404. Nothing changes after manually providing url in .env or twill.php. Seems to be Laravel 11 related.
7 Replies
ifox
ifox3mo ago
Hi @Adam Mateusz Brożyński are you serving the 2 apps differently? And when you installed did you use a preset or not? I noticed our basic-page-builder preset is conflicting with the root admin page because of the catch all route defined in the preset
Adam Mateusz Brożyński
This works: composer create-project laravel/laravel:^10.0 laravel cd laravel composer require area17/twill:"^3.3" php artisan twill:install basic-page-builder [just set sqlite database in .env because it's not default like in laravel 11] php artisan serve This gives 404 when going to /admin: composer create-project laravel/laravel twill-cms cd laravel composer require area17/twill:"^3.3" php artisan twill:install basic-page-builder php artisan serve The only difference is Laravel version.
I've tested without basic-page-builder and route works. Also there's no mention about /admin route in basic-page-builder README.md file on github and only: "go to your admin path, something like https://admin.laravel-twill.test" which is very missleading.
ifox
ifox3mo ago
This is legacy because Twill 2 used to default to the admin subdomain. On Twill 3 it should indeed link to /admin in that readme, thanks for pointing it out. As for the reason the basic-page-builder routing is an issue only with Laravel 11, I assume it's because the routes are not registered in the same order. Meaning twill routes are registered after your web.php routes in L11, and before in L10. We'll investigate further and may end up making it configurable if possible, because it isn't the first time we're running into route registration order conflicts between the package and the main app routes
Adam Mateusz Brożyński
Source of problem:
Route::get('{slug}', [\App\Http\Controllers\PageDisplayController::class, 'show'])->name('frontend.page');
Route::get('{slug}', [\App\Http\Controllers\PageDisplayController::class, 'show'])->name('frontend.page');
php artisan route:list:
GET|HEAD / ................. frontend.home › App\Http\Controllers\HomepageDisplayController@home
GET|HEAD admin ..............twill.dashboard › Admin\DashboardController@index
GET|HEAD admin/admin/icons ..twill.icons.index › Admin\IconsController@index
...
GET|HEAD {slug} ............ frontend.page › App\Http\Controllers\HomepageDisplayController@show
GET|HEAD / ................. frontend.home › App\Http\Controllers\HomepageDisplayController@home
GET|HEAD admin ..............twill.dashboard › Admin\DashboardController@index
GET|HEAD admin/admin/icons ..twill.icons.index › Admin\IconsController@index
...
GET|HEAD {slug} ............ frontend.page › App\Http\Controllers\HomepageDisplayController@show
I don't know why "/" is at the top and "{slug}" is at the bottom of the list since both paths are defined in same file. But when I do this then it works (partially because error 500 shows up on /admin when not logged in):
Route::get('/', [\App\Http\Controllers\PageDisplayController::class, 'home'])->name('frontend.home');
Route::get('/admin', [A17\Twill\Http\Controllers\Admin\DashboardController::class, 'index'])->name('twill.dashboard');
Route::get('/{slug}', [\App\Http\Controllers\PageDisplayController::class, 'show'])->name('frontend.page');
Route::get('/', [\App\Http\Controllers\PageDisplayController::class, 'home'])->name('frontend.home');
Route::get('/admin', [A17\Twill\Http\Controllers\Admin\DashboardController::class, 'index'])->name('twill.dashboard');
Route::get('/{slug}', [\App\Http\Controllers\PageDisplayController::class, 'show'])->name('frontend.page');
So basicaly after adding twill /admin route by hand it shows up the same in route:list but works differenty and not as expected because of error 500 when not logged in (/admin/login works but is not redirecting there).
zlem
zlem3w ago
Hi! Is there any news on this? I have a similar problem: Twill 3.3 & Laravel 11 set ADMIN_APP_PATH=/cmsadmin mydomain.com/cmsadmin -> 404 error mydomain.com/cmsadmin/login works, but all other links lead to 404 mydomain.com/cmsadmin/users works, and all other links work as well So far (until Laravel 11) it has worked well and I have not made any changes to twill
ifox
ifox2w ago
Hi @zlem we will prioritize this, sorry to hear. Do you also have a catch all route in your web.php (or any other routes files)?
zlem
zlem2w ago
@ifox yes, in web.php we have: Route::get('/{slug?}', [PageController::class, 'showPage']); Route::get('/', [PageController::class, 'showStartPage']);
Want results from more Discord servers?
Add your server