I'm currently developing a web app using Laravel, and the app was working perfectly fine until recently. I had no idea what triggered it but here's a summary of the issue I'm having:
Logging in used to work as I have an AccountController that does this:
$auth = Auth::attempt(array(
'username' => Input::get('username'),
'password' => Input::get('password'),
'active'=>1);
if ($auth) {
return Redirect::route('home');
}
return Redirect::route('account-sign-in');
And the home route looks like so:
Route::get('/', array('as'=>'home', 'use'=>'HomeController@show'));
The app would usually return to home page immediately upon successful login. And in my home.blade.php, I would have an @if(Auth::check())
in place to make sure that once a user is logged in, the home page would serve a different set of texts.
Recently however, I noticed that after submitting a request to log in, there's an intermediate page showing a message "Redirecting to http://localhost.com/
". The message was not there prior to this, and the errors started showing up along with this message.
I looked up all the information I can online, and someone suggested that there were line break/space issues with the source code. I looked at all the source code I had and nothing would've suggested there's something wrong.
Desperate at the time, I removed Redirect::route('home') and replaced that with View::make('home') instead. That stopped the message from showing up, and I'm able to login as usual again.
So I have two questions: 1) what is causing this odd issue? 2) is there anything wrong with using View::make() in this case vs Redirect::route()?
Thanks!
I faced same issue and after spending my whole weekend to find actual cause and fix this issue. I landed on this stackoverflow question and felt its same issue as that of mine.
I used following core php function to redirect instead of returning a view file from controller.
header('Location: /');
It printed actual file which had blank line. Removing this line fixed my problem.
There were thousands of files in my code base. My assumption was that I have tried different scripts to find such blank lines at start of any file and there was no such file as per those scripts results. I assumed there is is no blank line in any of my files. But header('Location: /') proved that my assumption was not correct and I was working on wrong lines.
I had the same problem, the problem for me was I had a space in the base controller before the <?php
tag
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With