Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 on all assets #917

Open
wdehoog opened this issue Aug 29, 2022 · 11 comments
Open

404 on all assets #917

wdehoog opened this issue Aug 29, 2022 · 11 comments

Comments

@wdehoog
Copy link

wdehoog commented Aug 29, 2022

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?

@klaussilveira
Copy link
Owner

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.

@wdehoog
Copy link
Author

wdehoog commented Aug 30, 2022

@klaussilveira
Copy link
Owner

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.

@wdehoog
Copy link
Author

wdehoog commented Aug 30, 2022

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
Copy link
Author

wdehoog commented Aug 30, 2022

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
Copy link
Author

wdehoog commented Aug 30, 2022

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
Copy link
Author

wdehoog commented Aug 30, 2022

@wdehoog
Copy link
Author

wdehoog commented Aug 31, 2022

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

@peelman
Copy link

peelman commented Oct 26, 2022

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

@mblythe86
Copy link

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.

@peelman
Copy link

peelman commented Sep 18, 2023

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

.setPublicPath('/assets')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants