Assets are loaded using the full system path, rather than relative web path
joachimtingvold opened this issue · 3 comments
Hi,
Just upgraded from 6.0.0-beta-something to latest RC. Also tested with fresh install, both produced the result below.
subfolder
variable is set to the full path of the files on the underlying system, and not relative to the web-root, causing assets to have wrong URL;
<!DOCTYPE html>
<html xml:lang="en-US" lang="en-US" dir="ltr">
<head data-headertemplate="header.twig">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet/less" href="/srv/vhosts/some.domain.foo/assets/themes/global.less" type="text/css" id="cssmain" />
<script src="/srv/vhosts/some.domain.foo/assets/js/polyfills.js" type="text/javascript"></script>
<script src="/srv/vhosts/some.domain.foo/assets/js/less.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="/srv/vhosts/some.domain.foo/assets/themes/default/global.css" type="text/css" id="csstheme" />
<link rel="stylesheet" href="/srv/vhosts/some.domain.foo/assets/vendor/jquery/jquery-ui.min.css" type="text/css" />
<link rel="shortcut icon" href="/srv/vhosts/some.domain.foo/assets/images/themes/default/Favicon.ico" type="image/vnd.microsoft.icon" />
<link rel="icon" href="/srv/vhosts/some.domain.foo/assets/images/themes/default/Introduction.png" type="image/png" />
<script src="/srv/vhosts/some.domain.foo/assets/vendor/jquery/jquery-3.4.1.min.js"></script>
<script src="/srv/vhosts/some.domain.foo/assets/vendor/jquery/jquery-ui.min.js"></script>
phpPgAdmin6 is served on domain some.domain.foo
directly in it's root, so all of the above should start with ./
or /
, rather than /srv/vhosts/some.domain.foo/
.
First hunch is that it's something wrong with the logic in src/classes/ContainerUtils.php
. The variables set is as follows;
<script>
window.stateObj = {
dir: 'ltr',
in_test: '0',
reload: '',
method: 'GET',
subfolder:'/srv/vhosts/some.domain.foo',
path:"/srv/vhosts/some.domain.foo//",
query_string:"",
strconfdropcred:"",
};
</script>
The relevant parts of the Apache vhost-config;
<VirtualHost *:443>
[…]
DocumentRoot /srv/vhosts/some.domain.foo/
<Directory "/srv/vhosts/some.domain.foo/">
DirectoryIndex index.php
AllowOverride All
Options +FollowSymLinks
SSLRequireSSL
Require all granted
</Directory>
</VirtualHost>
Damn, I'm sorry, I have neglected this project in last month of so. I haven't ever tried on Apache and I guess the vhost config as reccomended by Slim Framework may have changed.
Ok I believe I have figured this out. The problem is (as it has been since it begun) the attempt to figure out the subfolder.
I was currently relying on $_SERVER['DOCUMENT_ROOT']
so the subfolder would be defined as
str_replace(<DOC ROOT>, '', <PROJECT_ROOT>)
Which means, if the document root for phppga vhost was /var/www/phppga
and the project root was at /var/www/phppga/project
it sould mean the subfolder is project
however this is too brittle. Some webservers won't populate the DOCUMENT_ROOT, and in other scenarios any kind of symlinking rules (think capistrano deploys) will break the above.
This behavior was introduced by #28 and all this time I tried to infer the subdirectory. I won't anymore. From now on if you want to run in a subfolder that must be configured explicitly: