gitlist
gitlist copied to clipboard
404 on all assets
I just installed gitlist (from release 2.0.0 zip) on ubuntu 22.04 but no js or css file can be found. Firefox console shows 404 on all assets which all seem to expect to found at /assets
while giltist itself is located in /gitlist
.
My apache config is:
Alias /gitlist/ /home/exalon/intranet/www/gitlist/public/
<Directory /home/exalon/intranet/www/gitlist/public/>
Options FollowSymLinks
AllowOverride All
</Directory>
php itself is working since the latest nextcloud runs fine.
How/where can or should I configure the url for the assets?
Did you download the release zip/tarball, or cloned the repo? If you cloned the repo, you won't have the compiled assets, so you have to do it all by yourself by following the developer instructions.
I used the released zip file (https://github.com/klaussilveira/gitlist/releases/download/2.0.0/gitlist-2.0.0.zip)
Check this for the correct webserver configuration: https://symfony.com/doc/current/setup/web_server_configuration.html
Just replace /var/www/project
with your gitlist path.
I now have:
Alias /gitlist /home/exalon/intranet/www/gitlist/public
Alias /assets/ /home/exalon/intranet/www/gitlist/public/assets/
and the assets seem to be loaded. But this is not a nice solution. The assets of gitlist should preferably be accessible under /gitlist/assets
but the index.php always sends /assets
.
Another problem is that now all links to the repositories point to /gitlist/<reponame>
but do not work (404).
I have removed the alias for the assets and added a .htaccess to the public folder with contents (from the wiki):
<IfModule mod_rewrite.c>
Options -MultiViews +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /gitlist/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L,NC]
</ifmodule>
Now the repo links work but the assets still not (the url's remain /assets
)
I edited public/assets/entrypoints.json
to have all urls like /gitlist/...
and now it works.
I guess editing this file is not the way things are meant to be but I don't know what else I can try.
Maybe this is related: https://symfony.com/doc/current/frontend/encore/faq.html#my-app-lives-under-a-subdirectory
If I edit webpack.config.js
like below and do make build
the assets in the resulting public/
folder seem to be loaded successfully (but only when using the above mentioned .htaccess file).
.setPublicPath('/gitlist/assets')
.setManifestKeyPrefix('assets')
The overarching issue here seems to be the assumption by @klaussilveira that Gitlist is going to be at the root of the webserver. If you want to do http://server.tld/gitlist
this isn't going to work because all of the asset paths are built with an absolute URL of /assets/...
, this also goes for all routes within the app (to individual repos etc).
This is a little silly given how condensed gitlist tries to be, but this is the nature of FrameworkHell.
My guess is there are plenty of knobs and dials that could be adjusted in the deployment methodology, or as is done in many similar apps, a variable could be added to config.yaml
to adjust that "root" on the fly. But as it is, i'd be happy to see some exception catching for common errors like the dubious ownership problem (#903).
I had to modify a couple additional files to get everything working:
- add an
.htaccess
file with rewrites to send everything toindex.php
(as mentioned in this comment) - modify
/assets/
paths inpublic/assets/entrypoints.json
(as mentioned in this comment) - modify
/assets/
paths inpublic/assets/manifest.json
- modify
/assets/
paths inpublic/assets/default/css/main.css
- modify
/assets/
string inpublic/assets/ace/js/main.js
as is done in many similar apps, a variable could be added to config.yaml to adjust that "root" on the fly
I'd love to see this. I've also worked with a few web apps that were agnostic to their URL root. I'm not sure whether this was because they are somehow automatically determining the root, or if they're only using relative URL paths.
FYI, if a location-agnostic .htaccess
file is needed, I've had good luck using the technique here.
So after having issues deploying v2, and a string of issues with v1 and #903, I gave up and used Klaus for a while. I harbor a hatred for Python, so between that and it being ugly as sin, I gave gitlist a try on a whim this morning, and using @mblythe86's approach, its working, and I can't find anything obviously broken.
It sure does seem like this line is the root of at least some of the evil (pun not intended):
https://github.com/klaussilveira/gitlist/blob/dd98962de9bff0d45d248b8f658d8dd2b12e5b50/webpack.config.js#L15