Open philosim opened 1 year ago
Maybe I`m wrong. But why your application layer knows about k8s, LB and etc? Why you don`t want to configure the right PHP environment?
My application layer knows nothing about k8s, it's just a simple webapp running on nginx. what do you mean by "configure PHP environment"? php also knows nothing about internal hostnames ...
what do you mean by "configure PHP environment"
Set correct nginx headers for redirects and set server host info https://github.com/yiisoft/yii2/blob/master/framework/web/Request.php#L754 look at comment to Request::getHostInfo
Request Headers are set, working as expected under normal circumstances. It is a very complex environment, I am still trying to figure out why they won't in some cases.
But nonetheless, the question is: why would someone expect a redirect function to always add the hostinfo? Its clearly not necessary and I can't really image any case one would need this - if a want to redirect to am absolute URI I would do so. Could live with a scheme parameter as in Url::to() which defaults to false though ...
What steps will reproduce the problem?
In Controller use redirect() function to redirect to relative location:
In View use Gridview with Pjax enabled and actioncolumn view button pointing to ["view2","id"=>$model->id].
What is the expected result?
Response should sent Header Location /controller/view?id=$id and Status Code 302
What do you get instead?
Response sends Location https://myserver.intern:8002/view?id=$id
// UPDATE
It only happens in when using PJAX (in a gridview), Response does not send header-location, the Response is 302 with:
X-Pjax-Url https://myserver.intern:8002/view?id=$id
Additional info
To be fair, it is in the docs that redirect will act like this:
Question is: why? Header-Location definitely accepts relative URLs and there is no reason to add the internal getHostInfo() to every redirect. In k8s environments (or any other situation using a proxy redirect, loadbalancer, ...) one will have to use own redirect functions, since the internal hostinfo URL is not always available from outside clients.