dimanche 8 décembre 2019

Laravel auth middleware not keeping query string after redirect

We have a link which has some UTM code at the end like this:

https://website.com/guides/playing-live-touring/show-budget?utm_source=hubspot_weekly3_&utm_medium=email&utm_term=&utm_content=&utm_campaign=hubspot_weekly3_showbudget_19_11_12&utm_nooverride=1

This link is a gated page, so of course, the user is 302 redirected to https://website.com/login, but the query string is not kept.

I tried modifying the redirectTo method in the Authenticate middleware from

protected function redirectTo($request)
{
    if (! $request->expectsJson()) {
        return route('login');
    }
}

to

protected function redirectTo($request)
{
    if (! $request->expectsJson()) {
        return route('login', $request->query());
    }
}

but to no avail. Which is weird, because echoing route('login', $request->query()) shows the correct URL.

Any ideas are appreciated!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire