You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
That means relative paths in assets like images and stylesheets would not work since they would be passed outside virtual host and managed by NTNU's own rules often resulting in 404. Hard coding (absolute path) is also not feasible since local development builds would end up fetching assets from live server. This is important since you don't want to be able to perform destructive actions on live server when developing. The running script needs to figure out if it's being run under a virtual host and prepend virtual host path to all assets if so.
Current solution is a hard coded baseurl inside settings/settings.json (generated from docker/docker.json). That is not optimal since if there is a mismatch between baseurl in settings.json and an alias. Think 127.0.0.1, localhost, 192.168.0.xxx or even custom hostname like mylaptop.local. Also when accessing the web site from another client on local network (like a phone or a tablet) then they would obviously get a 404 if any assets are located on "localhost" from the perspective of the client.
var_dump()-ing the super global $_SERVER in both production and in development contains a key called SCRIPT_NAME. It contains values /svommer/index.php in production and /index.php in development. Transforming that string with following function would extract (if any) virtual host present (even nested virtual hosts)
Currently the project is hosted at a university server within a virtual host like so:
That means relative paths in assets like images and stylesheets would not work since they would be passed outside virtual host and managed by NTNU's own rules often resulting in 404. Hard coding (absolute path) is also not feasible since local development builds would end up fetching assets from live server. This is important since you don't want to be able to perform destructive actions on live server when developing. The running script needs to figure out if it's being run under a virtual host and prepend virtual host path to all assets if so.
Current solution is a hard coded
baseurl
insidesettings/settings.json
(generated fromdocker/docker.json
). That is not optimal since if there is a mismatch betweenbaseurl
insettings.json
and an alias. Think127.0.0.1
,localhost
,192.168.0.xxx
or even custom hostname likemylaptop.local
. Also when accessing the web site from another client on local network (like a phone or a tablet) then they would obviously get a 404 if any assets are located on "localhost" from the perspective of the client.var_dump()
-ing the super global$_SERVER
in both production and in development contains a key calledSCRIPT_NAME
. It contains values/svommer/index.php
in production and/index.php
in development. Transforming that string with following function would extract (if any) virtual host present (even nested virtual hosts)The output of that function can be safely prepended to any relative path as it returns an empty string if no virtual host is present.
$_SERVER["SCRIPT_NAME"]
value is not going anywhere soon as it's a part of CGI 1.1 specification. Related SO answer.The text was updated successfully, but these errors were encountered: