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

mathewparet's avatar

Email verification / URL redirection issue after upgrading from Laravel 7 to 8

I built a VPN self-service portal (for the OpenVPN community edition) using Laravel 7. I am now trying to upgrade it to 10 step by step and the first step is to upgrade to 8.

After going through the upgrade docs I have an issue with URL redirection when it is protected by the verify middleware that comes with Laravel.

  1. All user accounts should be verified before the website can be used
  2. After registration, the user is automatically logged in and redirected to /home.
  3. Since the user isn't verified yet, this will redirect the user to /email/verify.

Before upgrading to 8, this redirection worked without issues.

The registration form is vue based and uses window.location to redirect user after successful login:


            registerAccount()
            {
                this.formCopy = JSON.parse(JSON.stringify(this.form));
                this.form.post(`/api/register`)
                    .then(response => {
                        var regResponse = response;
                        axios.get('/sanctum/csrf-cookie').then(response => {
                            axios.post('/login', {email: this.formCopy.email, password: this.formCopy.password})
                                .then(response => {
                                    this.formCopy.password = null;
                                    this.formCopy.password_confirmation = null;
                                    this.message = regResponse.message;
                                    window.location = regResponse.to;
                                });
                        });
                    })
                    .catch(error => {
                        console.log(error);
                    });
            }

The redirection is attempted but seems to attempt over xhr instead of redirecting the browser:

But if I visit the URL directly on the browser it works:

Visiting http://localhost/home redirects to http://localhost/email/verify as expected and this is what I want to happen with the above window.location code.:

How do I fix this?

0 likes
1 reply
mathewparet's avatar

It's been three days, and I'm still stuck with this. Any help would be appreciated. Thanks.

Please or to participate in this conversation.