gitlist icon indicating copy to clipboard operation
gitlist copied to clipboard

404 on all assets

Open wdehoog opened this issue 2 years ago • 11 comments

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?

wdehoog avatar Aug 29 '22 18:08 wdehoog

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.

klaussilveira avatar Aug 30 '22 14:08 klaussilveira

I used the released zip file (https://github.com/klaussilveira/gitlist/releases/download/2.0.0/gitlist-2.0.0.zip)

wdehoog avatar Aug 30 '22 14:08 wdehoog

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.

klaussilveira avatar Aug 30 '22 14:08 klaussilveira

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).

wdehoog avatar Aug 30 '22 16:08 wdehoog

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)

wdehoog avatar Aug 30 '22 16:08 wdehoog

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.

wdehoog avatar Aug 30 '22 16:08 wdehoog

Maybe this is related: https://symfony.com/doc/current/frontend/encore/faq.html#my-app-lives-under-a-subdirectory

wdehoog avatar Aug 30 '22 17:08 wdehoog

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')

wdehoog avatar Aug 31 '22 13:08 wdehoog

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).

peelman avatar Oct 26 '22 17:10 peelman

I had to modify a couple additional files to get everything working:

  • add an .htaccess file with rewrites to send everything to index.php (as mentioned in this comment)
  • modify /assets/ paths in public/assets/entrypoints.json (as mentioned in this comment)
  • modify /assets/ paths in public/assets/manifest.json
  • modify /assets/ paths in public/assets/default/css/main.css
  • modify /assets/ string in public/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.

mblythe86 avatar Nov 11 '22 22:11 mblythe86

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

peelman avatar Sep 18 '23 12:09 peelman