thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

Laravel Breeze breaks Voyager admin route #5288

Closed chrisurf closed 3 years ago

chrisurf commented 3 years ago

Version information

Description

After user authentication to my domain.com/admin redirects to domain.com and not to the admin panel. Unauthorised users can see the voyager login form (domain.com/admin).

I tried the following...

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install Laravel, Voyager and breeze
  2. Sign in as admin user
  3. open domain.com/admin
  4. redirects to domain.com

Expected behavior

domain.com/admin should open the voyager admin panel.

Additional context

composer.json { "name": "laravel/laravel", "type": "project", "description": "The Laravel Framework.", "keywords": [ "framework", "laravel" ], "license": "MIT", "require": { "php": "^7.3|^8.0", "fideloper/proxy": "^4.4", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", "laravel/framework": "^8.12", "laravel/tinker": "^2.5", "livewire/livewire": "^2.4", "tcg/voyager": "^1.4" }, "require-dev": { "facade/ignition": "^2.5", "fakerphp/faker": "^1.9.1", "laravel/breeze": "^1.1", "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.2", "nunomaduro/collision": "^5.0", "phpunit/phpunit": "^9.3.3" }, "autoload": { "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/" } }, "autoload-dev": { "psr-4": { "Tests\\": "tests/" } }, "scripts": { "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ] }, "extra": { "laravel": { "dont-discover": [] } }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true }, "minimum-stability": "dev", "prefer-stable": true, "repositories": { "hooks": { "type": "composer", "url": "https://larapack.io" } } }

package.json { "private": true, "scripts": { "dev": "npm run development", "development": "mix", "watch": "mix watch", "watch-poll": "mix watch -- --watch-options-poll=1000", "hot": "mix watch --hot", "prod": "npm run production", "production": "mix --production" }, "devDependencies": { "@tailwindcss/forms": "^0.2.1", "alpinejs": "^2.7.3", "autoprefixer": "^10.1.0", "axios": "^0.21", "laravel-mix": "^6.0.6", "lodash": "^4.17.19", "postcss": "^8.2.1", "postcss-import": "^12.0.1", "tailwindcss": "^2.1.1" } }

snim2 commented 3 years ago

Is there a workaround for this BTW?

chrisurf commented 3 years ago

Is there a workaround for this BTW?

I've not found any

RahulHuilgol commented 3 years ago

I have the same issue. How does one work with Laravel authentication using Breeze/JetStream and an admin panel like Voyager?

emptynick commented 3 years ago

I just tried the following:

  1. Install Laravel (8.5.17)
  2. Install Breeze (1.1.7) => run php artisan breeze:install
  3. Install Voyager (1.x-#d5559d2) => run php artisan voyager:install --with-dummy

And I can use both logins without a problem. Could you guys update and see if the problem still exists?

RahulHuilgol commented 3 years ago

Does the sequence of installation of Breeze and Voyager matter? I installed Voyager first and then Breeze.

emptynick commented 3 years ago

Don't think so. I will try later.

Edit: Installing Breeze overrides the routes. Check if routes/web.php still includes voyagers routes.

RahulHuilgol commented 3 years ago

Hi Christoph, the contents of my routes/web.php are:

Route::get('/', function () {
    return view('welcome');
});

Route::get('/dashboard', function () {
    return view('dashboard');
})->middleware(['auth'])->name('dashboard');

require __DIR__.'/auth.php';

I guess you're right. Breeze overrides the routes set in by Voyager. I'll try afresh.

emptynick commented 3 years ago

That makes sense. Simply add this to the end of routes/web.php:

Route::group(['prefix' => 'admin'], function () {
    Voyager::routes();
});
RahulHuilgol commented 3 years ago

Alright! That works! I can access /admin and the other routes as expected. Thanks a ton, Christoph!!!

emptynick commented 3 years ago

Sweet.

Closing as we can't do anything about it. Here's what you can do:

  1. You either install Voyager after Breeze
  2. Add back Voyagers routes after installing Breeze (see above)
  3. Simply run php artisan voyager:install again
github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.