Still a noob as it comes to PHP and learning a lot from all the messages.
I have some difficulties as it comes to some function (and completely understand them).
When I use the normal function (TwigExtension):
public function baseUrl()
{
if (is_string($this->uri)) {
return $this->uri;
}
if (method_exists($this->uri, 'getBaseUrl')) {
return $this->uri->getBaseUrl();
}
}
If you are getting the port number 80, and HTTPS, then something is strange in your environment. What does $_SERVER look like? Are you intending to run under HTTPS? Are you behind any sort of reverse proxy or caching server?
I am not sure what is happening on the Server of the provider. I attend to run everything under a https (for a more secure) connection.
Here are the server details. Let me know if this is of any use?
Is can see that the [âHTTP_X_FORWARDED_PROTOâ] is âhttpsâ but the [âREQUEST_SCHEMEâ] is âhttpâ and the [âSERVER_PORTâ] is â80â.
Donât understand how I have to âreadâ this combination of data and is this okay or wrong?
P.s. as Kalvn suggested in this ([SOLVED] Twig base_url() returns port 80 when used over HTTPS connection) topic it would not be handy to adjust code in the external libraries.
Although the issue is properly the combination of the server and the $request->getUri()->getBaseUrl(); function.
Is it possible to adjust this code for the (future) Slim libaries or perhaps some extra code to bypass this in the bootstrap\app.php instead? (donât fully understand what is happening at the server side).
Slim looks to be doing exactly what it is supposed to do. The issue is your server configuration as you are running HTTPS under port 80, which is not standard. You will either need to change your server configuration to run under the standard HTTPS port (443), or perhaps set a Twig global variable at runtime with your desired base URL.
In instances such as yours, the most common reason is that your server environment is running behind some sort of caching server or CDN. So while the request is HTTPS, the front caching server is HTTPS, but Apache behind the scenes is running on port 80.
What I do in similar instances is described in this post.