Laravel 中的位置标头

2022-01-11 00:00:00 location header redirect php laravel

我正在为我大学的身份验证系统 (Ucam_Webauth) 使用图书馆,这意味着我必须通过其中一种方法重定向到身份验证服务器.不幸的是,由于该库的体系结构,我无法返回 Redirect:to().该库本身使用 header('Location: ...'); 但这由于某种原因不起作用.

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.

如果我在发送标头后使程序 die(); 可以工作,否则就不行.

If I make the programme die(); after sending the header it works, but otherwise it doesn't.

知道如何解决这个问题吗?

Any idea how I can fix this?

推荐答案

return redirect()->to('url')->send();

发送 HTTP 标头和内容.在我的应用程序中,send() 方法的作用类似于 'exit()' 并且是可测试的

Sends HTTP headers and content. In my application, send() method acts like 'exit()' and is testable

相关文章