hotwired-laravel / turbo-laravel

This package gives you a set of conventions to make the most out of Hotwire in Laravel.
https://turbo-laravel.com
MIT License
803 stars 50 forks source link

"return redirect" fully reloads the page #90

Closed pasindujr closed 2 years ago

pasindujr commented 2 years ago

I have been developing a Laravel 9 application with Livewire and using Turbo Laravel package for give it a SPA feeling. It works fine with regular links, but there is a register page in my application and after registration is successful, I have given a redirect to the same page. but after I clicked the register button the page does a full reload. How can I fix that? Is this a issue with the package. I have tried different redirect notations but the issue remains.

$user = new User;
        $user->name = $this->name;
        $user->username = $this->username;
        $user->gender = $this->gender;
        $user->user_image_path = $userImageName;
        $user->email = $this->email;
        $user->password = Hash::make($this->password);
        $save = $user->save();

        if ($save) {
            return redirect('/regsiter');
        } else {
            return $this->error = 'Something went wrong! Please try again.';
        }
stevebrainng commented 2 years ago

redirecting to the same page will trigger a full page reload because you are on the same page. try return redirecting to login page to see if it works...

pasindujr commented 2 years ago

redirecting to the same page will trigger a full page reload because you are on the same page. try return redirecting to login page to see if it works...

I tried that but did not work.

stevebrainng commented 2 years ago

Try redirecting to a named route... return redirect()->route('register');

tonysm commented 2 years ago

@pasindujr where is this redirect happening? Is that in a Livewire action? Or a controller action? Can you provide a sample application code where this happens? I'd recommend creating a fresh Laravel app where this error happens and publishing that to GitHub.

tonysm commented 2 years ago

Closing this for now since I didn't get an answer and doesn't seem like an issue for this package. Feel free to reopen it if you think it is and, pls, try creating a demo app where you're able to reproduce the issue, publish that to GitHub and share with me.