Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

636
Views
Laravel login error 'Header may not contain more than a single header, new line detected laravel login'

I am making a multi-auth custom login for clients. The login/logout works fine the first time I login, but shows this error in the second attempt

ErrorException in Response.php line 339: Header may not contain more than a single header, new line detected'

what may be the cause for this?

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

I'm facing same issue. Watching closely, I noticed that the header that is being passed contains not just a newline char, but also html code. A code for a page just annoucing the redirection to the route I wanted it to redirect.

My login is redirectTo is

/**
 * Where to redirect users after login.
 *
 * @return string
 */
protected function redirectTo()
{
    return redirect()->route((string)\Auth::user()->group->type);
}

Where already exists a named route for each group->type possible.

I've already tried just a return to the route path with no success or any different error message.

[UPDATE] I found a fix here, changed my code to this and it worked:

protected function redirectTo()
{
    // return redirect()->route((string)\Auth::user()->group->type);
    return route(\Auth::user()->group->type);
}
about 4 years ago · Santiago Trujillo Report

0

you should use

return route('admin.dashboard');

instead of

 return redirect('admin/dashboard');
about 4 years ago · Santiago Trujillo Report

0

Try it in LoginController.

public function redirectTo(){

   $user_id = Auth::user()->id;

   $role_manager = User::where('id', $user_id)->value('role');

   if($role_manager == 'manager'){

       return $this->redirectTo = 'dashboard';

   }
}
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!