Rafli's avatar
Level 1

Page Not Found Laravel Breeze login

please help me... so I use laravel 11 then use the breeze package... two days ago it was running normally but today when I opened localhost:8000/login page not found 404... but when I looked at the route controller and view there was ... I've tried using PHP Artisan Optimize and it still doesn't appear

0 likes
19 replies
vincent15000's avatar

You have necessarily changed something.

Have you checked that the login route is still available ?

php artisan route:list

1 like
Rafli's avatar
Level 1

@vincent15000 <?php

use App\Http\Controllers\HomeController; use App\Http\Controllers\ProfileController; use App\Http\Controllers\SuperAdminController; use App\Http\Controllers\ManagerController; use App\Http\Controllers\KasirController; use App\Http\Controllers\MenuController; use App\Http\Controllers\ProductController; use App\Http\Controllers\CategoryController; use App\Http\Middleware\SuperAdmin; use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Auth; use App\Http\Controllers\DiscountProductController; use App\Http\Controllers\SliderController; use App\Http\Controllers\Auth\AuthenticatedSessionController; // Resource routes for products and categories Route::prefix('categories')->group(function () { Route::get('/index', [CategoryController::class, 'index'])->name('categories.index'); Route::get('/create', [CategoryController::class, 'create'])->name('categories.create'); Route::post('/', [CategoryController::class, 'store'])->name('categories.store'); Route::get('/{category}/edit', [CategoryController::class, 'edit'])->name('categories.edit'); Route::put('/{category}', [CategoryController::class, 'update'])->name('categories.update'); Route::delete('/{category}', [CategoryController::class, 'destroy'])->name('categories.destroy'); })->middleware(['auth', 'verified', 'superadmin']);

Route::prefix('products')->group(function () { Route::get('/create', [ProductController::class, 'create'])->name('products.create'); Route::post('/', [ProductController::class, 'store'])->name('products.store'); Route::get('/', [ProductController::class, 'index'])->name('products.index'); Route::get('/{product}/edit', [ProductController::class, 'edit'])->name('products.edit'); Route::put('/{product}', [ProductController::class, 'update'])->name('products.update');

Route::get('/addstock', [ProductController::class, 'addstock'])->name('products.addstock');
Route::delete('/{product}', [ProductController::class, 'destroy'])->name('products.destroy');

})->middleware(['auth', 'verified', 'superadmin', 'manager']);

// routes/web.php

Route::post('/product/info', [ProductController::class, 'getProductInfo'])->name('product.info'); Route::post('/products/updatestock', [ProductController::class, 'updatestock'])->name('products.updatestock');

Route::get('/display', [ProductController::class, 'display'])->name('products.display'); Route::get('/{product}', [ProductController::class, 'show'])->name('products.show');

Route::resource('sliders', SliderController::class);

// Route::get('/discount-products', [DiscountProductController::class, 'index']);

// Grouped routes for menus with a prefix Route::prefix('menus')->group(function () { Route::get('/index', [MenuController::class, 'index'])->name('menus.index'); Route::get('/create', [MenuController::class, 'create'])->name('menus.create'); Route::post('/', [MenuController::class, 'store'])->name('menus.store'); Route::get('/{menu}/edit', [MenuController::class, 'edit'])->name('menus.edit'); Route::put('/{menu}', [MenuController::class, 'update'])->name('menus.update'); Route::delete('/{menu}', [MenuController::class, 'destroy'])->name('menus.destroy'); })->middleware(['auth', 'verified', 'superadmin']);

Route::prefix('superadmin')->group(function () { Route::get('/', [SuperAdmin::class, 'index'])->name('superadmin.index'); })->middleware(['auth', 'verified', 'superadmin']);

// Dashboard route Route::get('/', [HomeController::class, 'index']) ->name('dashboard');

// Grouped routes for profile with authentication middleware Route::middleware('auth')->group(function () { Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit'); Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update'); Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy'); });

// Authentication routes require DIR . '/auth.php';

1 like
Rafli's avatar
Level 1

@vincent15000 <?php

use App\Http\Controllers\Auth\AuthenticatedSessionController; use App\Http\Controllers\Auth\ConfirmablePasswordController; use App\Http\Controllers\Auth\EmailVerificationNotificationController; use App\Http\Controllers\Auth\EmailVerificationPromptController; use App\Http\Controllers\Auth\NewPasswordController; use App\Http\Controllers\Auth\PasswordController; use App\Http\Controllers\Auth\PasswordResetLinkController; use App\Http\Controllers\Auth\RegisteredUserController; use App\Http\Controllers\Auth\VerifyEmailController; use Illuminate\Support\Facades\Route;

Route::middleware('guest')->group(function () { Route::get('register', [RegisteredUserController::class, 'create']) ->name('register');

Route::post('register', [RegisteredUserController::class, 'store']);

Route::get('login', [AuthenticatedSessionController::class, 'create'])
            ->name('login');

Route::post('login', [AuthenticatedSessionController::class, 'store']);

Route::get('forgot-password', [PasswordResetLinkController::class, 'create'])
            ->name('password.request');

Route::post('forgot-password', [PasswordResetLinkController::class, 'store'])
            ->name('password.email');

Route::get('reset-password/{token}', [NewPasswordController::class, 'create'])
            ->name('password.reset');

Route::post('reset-password', [NewPasswordController::class, 'store'])
            ->name('password.store');

});

Route::middleware('auth')->group(function () { Route::get('verify-email', EmailVerificationPromptController::class) ->name('verification.notice');

Route::get('verify-email/{id}/{hash}', VerifyEmailController::class)
            ->middleware(['signed', 'throttle:6,1'])
            ->name('verification.verify');

Route::post('email/verification-notification', [EmailVerificationNotificationController::class, 'store'])
            ->middleware('throttle:6,1')
            ->name('verification.send');

Route::get('confirm-password', [ConfirmablePasswordController::class, 'show'])
            ->name('password.confirm');

Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']);

Route::put('password', [PasswordController::class, 'update'])->name('password.update');

Route::post('logout', [AuthenticatedSessionController::class, 'destroy'])
            ->name('logout');

});

1 like
Snapey's avatar

@Rafli dot run optimize unless this is production

Maybe you have ticked 'remember me' so are being automatically logged in and then redirected to a page that is showing a 404

Try the same login route in an incognito window

1 like
Rafli's avatar
Level 1

@Snapey still can't... I don't know what's wrong I've tried all the methods on the internet

1 like
Snapey's avatar

@Rafli still cant... what? Your problem will be very simple but you need to do some tests and report back.

1 like
Rafli's avatar
Level 1

@Snapey I have tried dump and die in my login controller but it doesn't show up

MohamedTammam's avatar
Level 51

You have a route that override the login route.

Route::get('/{product}', [ProductController::class, 'show'])->name('products.show');

Put your auth routes at the top of the file.

3 likes
Snapey's avatar

@vincent15000 The product route is greedy and will treat 'login' as the ID of a product. as it comes before login, the authentication routes will never be reached.

@mohamedtammam has the right answer

2 likes

Please or to participate in this conversation.