I'm working with a Library for my university's authentication system (Ucam_Webauth) which means I have to redirect to the authentication server in one of the methods. Unfortunately, I cannot return a Redirect:to()
because of the architecture of this library. The library itself uses header('Location: ...');
but this isn't working for some reason.
If I make the programme die();
after sending the header it works, but otherwise it doesn't.
Any idea how I can fix this?
Laravel provides many details in Illuminate\Http\Request class object. You can simply get headers details using headers() method. This will return all headers in array.
The Location response header indicates the URL to redirect a page to. It only provides a meaning when served with a 3xx (redirection) or 201 (created) status response.
PHP Header Location In order for your PHP redirect to be successful, the header() function must execute — and before any output is sent. This is why your code must appear above the <! DOCTYPE html> or <html> tags in your index. php file.
return redirect()->to('url')->send();
Sends HTTP headers and content. In my application, send() method acts like 'exit()' and is testable
I'm not sure I follow. Laravel sets the Location header as part of the Redirect::to() method. If you want to more explicitly define the response you could do it like this.
return Response::make( '', 302 )->header( 'Location', $url );
If that doesn't work I'd probably just fall back on the php stdlib header() and return null.
If all of this still doesn't do any good, maybe the profiler is messing things up. If it is turned on, try disabling it in the config.
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