Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lokisapocalypse's avatar

Redirect not changing route

Hello all,

I'm having a weird issue with a redirect not actually changing the url. In my application, I have:

return redirect()->route('training');

And verified that that route works and exists. When I hit the controller that should handle the redirect, I get a message that says "Aw snap" and the page doesn't change.

However, when I look chrome dev tools, it looks like it is trying to go to /training and it is a 200. But nothing is actually happening in the application itself.

What am I missing here?

0 likes
4 replies
hotsaucejake's avatar

Might help to see the logic before the redirect. The Aw snap message is from chrome having trouble loading the page

lokisapocalypse's avatar

Thanks for the reply. It's a pretty simple method:

    {
        $credentials = $request->validate([
            'email' => ['required'],
            'password' => ['required'],
        ]);

        if (Auth::attempt($credentials)) {
            $request->session()->regenerate();

            return redirect()->route('training');
        }

        return redirect()->route('login')->withErrors([
            'email' => 'The provided credentials do not match our records.',
        ])->onlyInput('email');
    }

I think it's something Javascript related but I can't fathom what it would be. Once it attempts to load the training page this way, if I navigate there manually, it works fine.

lokisapocalypse's avatar

I should clarify, the aw snap shows up in a red button, not on the page itself. When I look at the request in the dev tools, it looks like the html is there but none of the styles.

hotsaucejake's avatar

Ah, authentication. I believe that page is erroring because of too many redirects (but not necessarily). Reconfiguring the default authentication has been tricky for me in the past too. What version of Laravel are you using?

If you're using other defaults with login, there's a protected $redirectTo variable you can set upon successful authentication.

Please or to participate in this conversation.