Redirecting to an external URL from a POST request
Hi everyone,
I'm trying redirect my users to an external URL after a form submission in a POST request.
public function store(Request $request) {
return redirect()->away("https://google.com");
}
When I submit the form, nothing happens. The form is still displayed. But if I insert dd() to check if my routing is correct, a blank page shows up as expected.
public function store(Request $request) {
dd();
return redirect()->away("https://google.com");
}
@rapido your original post looks good and should work fine.
As @fylzero mention, there might be somewhere in your code that is messing up the redirect.
Also, are you for some reason using Livewire? If so, there is some issue on redirect when using Laravel with Livewire. Check out the link below and see if the answers there can solve your problem including using of $this->redirect('/url'); without a return.