PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, February 3, 2022

[FIXED] laravel redirect with white screen and message "redirecting to..." breaks posts

 February 03, 2022     apache, apache2, laravel, mamp, redirect     No comments   

Issue

I have been working with Laravel for quite a while, and encountered a problem with MAMP today. I can't track down its roots since I didn't do a composer update or any other software change that could cause it. Anyways, the problem breaks down the login form on my website on localhost (there is no problem in production, or in the same project on WAMP that my friend is using). The issue makes itself apparent by printing out "redirecting to ..." messages on the screen when a redirect is happening in the application. after submitting my login form I am getting this message and being redirected back to the login page. From what I found on the web the issue might be in the fact that doing redirects somehow kills my post data that should be checked with the login action, thus authentication attempt fails and I am being redirected back to login form. Apparently the error message from auth::attempt is being lost along the way of redirects as well. I have encountered someone facing the same problem and fixing it with nginx, but since I am using mamp with apache2, I couldn't find how to perform the same trick with it. No errors are being logged with this issue. Any ideas on how this can be fixed please?


Solution

I had exactly the same error, and I tried all type of solutions: nginx, filtering, spaces at the end of files.

After several hours, I decided to look for spaces at the end of files again, and that was it: Right after the Auth::attempt, I was setting up a Session variable using a Model that had a line break after ?>

This was causing Laravel to show the "Redirecting to..." message, and because it was shown, the session was lost, so the user was not logged in.

This was a Server error only, on my Localhost it always worked fine with spaces.

Hope it helps



Answered By - ecairol
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing