Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent 404s after login on Laravel 9 #8

Open
joereynolds opened this issue Nov 30, 2022 · 4 comments
Open

Consistent 404s after login on Laravel 9 #8

joereynolds opened this issue Nov 30, 2022 · 4 comments

Comments

@joereynolds
Copy link

Hello!

I saw issue #4 and I thought it might solve my problem but unfortunately it doesn't help.

The problem

After installing the project via composer, I then add the middleware:

diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index 9fb429db..2a6c3058 100644
--- a/app/Http/Kernel.php
    b/app/Http/Kernel.php
@@ -35,6  35,7 @@ class Kernel extends HttpKernel
             \App\Http\Middleware\EncryptCookies::class,
             \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
             \Illuminate\Session\Middleware\StartSession::class,
             \CodeZero\StageFront\Middleware\RedirectIfStageFrontIsEnabled::class,
             // \Illuminate\Session\Middleware\AuthenticateSession::class,
             \Illuminate\View\Middleware\ShareErrorsFromSession::class,
             \App\Http\Middleware\VerifyCsrfToken::class,

(Note this is the only place to add it, there is no $middlewarePriority for Laravel 9 from what I can tell).

After this, I add these .env values

STAGEFRONT_ENABLED=TRUE
STAGEFRONT_LOGIN=test
STAGEFRONT_PASSWORD=password

The stagefront page loads successfully but any successful or unsuccessful logins get immediately redirected to a 404.
I have cleared and populated the cache with route:cache and ran into the same problems.

Thanks, and I hope you can help!

@ivanvermeyen
Copy link
Contributor

I believe $middlewarePriority is not in the kernel by default.
You have to copy it from the base class.

@joereynolds
Copy link
Author

After copying Laravel's $middlewarePriority over (and doing a ./artisan route:cache), it's still giving the same error unfortunately :(

diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index 9fb429db..494a7dd2 100644
--- a/app/Http/Kernel.php
    b/app/Http/Kernel.php
@@ -25,6  25,20 @@ class Kernel extends HttpKernel
         \App\Http\Middleware\FixNewRelicUnknownTransactionMiddleware::class,
     ];
 
     protected $middlewarePriority = [
         \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
         \Illuminate\Cookie\Middleware\EncryptCookies::class,
         \Illuminate\Session\Middleware\StartSession::class,
         \CodeZero\StageFront\Middleware\RedirectIfStageFrontIsEnabled::class,
         \Illuminate\View\Middleware\ShareErrorsFromSession::class,
         \Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests::class,
         \Illuminate\Routing\Middleware\ThrottleRequests::class,
         \Illuminate\Routing\Middleware\ThrottleRequestsWithRedis::class,
         \Illuminate\Contracts\Session\Middleware\AuthenticatesSessions::class,
         \Illuminate\Routing\Middleware\SubstituteBindings::class,
         \Illuminate\Auth\Middleware\Authorize::class,
     ];
 
     /**
      * The application's route middleware groups.
      *

@ivanvermeyen
Copy link
Contributor

Can you track where it is redirecting to?

On success it should redirect to the "intended" route or "/".
On error it should redirect back with errors as per default validation behavior.

https://github.com/codezero-be/laravel-stagefront/blob/master/src/Controllers/StageFrontController.php

@joereynolds
Copy link
Author

joereynolds commented Nov 30, 2022

Yes, so the login is at:

https://my-domain.local.test.io/myprefixed/path/stagefront/

And on either failure or success it goes to:

https://my-domain.local.test.io/myprefixed/path/stagefront/stagefront/

No validation errors come through.
I'll try and debug further when I get the chance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants