spiral-project / ihatemoney

A simple shared budget manager web application
https://ihatemoney.org
Other
1.18k stars 267 forks source link

Fix APPLICATION_ROOT example in docs #1270

Closed aristocrates closed 10 months ago

aristocrates commented 10 months ago

If the application is hosted on the path /somestring, static asset paths need to have prefix /somestring/static/ but setting APPLICATION_ROOT to "somestring" will result in a relative path which will give a 4XX. Using "/somestring" fixes this.

e.g. static assets should look like this in source:

<link rel="stylesheet" type="text/css" href="/somestring/static/css/main.css">

but without the leading slash they have href="somestring/static/css/main.css" which results in a network request for {DOMAIN}/somestring/{PROJECT_NAME}/somestring/static/css/main.css

The test suite includes the leading slash in test_prefixed:

https://github.com/spiral-project/ihatemoney/blob/76e8b3baf0b52d098c1287f01ebf30cdeeb6ecc5/ihatemoney/tests/main_test.py#L76-L77


Also fix default value, which is "/" and not the empty string:

https://github.com/spiral-project/ihatemoney/blob/76e8b3baf0b52d098c1287f01ebf30cdeeb6ecc5/ihatemoney/default_settings.py#L13

https://github.com/spiral-project/ihatemoney/blob/76e8b3baf0b52d098c1287f01ebf30cdeeb6ecc5/Dockerfile#L29

https://github.com/spiral-project/ihatemoney/blob/76e8b3baf0b52d098c1287f01ebf30cdeeb6ecc5/docker-compose.yml#L38

https://github.com/spiral-project/ihatemoney/blob/76e8b3baf0b52d098c1287f01ebf30cdeeb6ecc5/ihatemoney/conf-templates/ihatemoney.cfg.j2#L50-L51

https://github.com/spiral-project/ihatemoney/blob/76e8b3baf0b52d098c1287f01ebf30cdeeb6ecc5/ihatemoney/tests/main_test.py#L72

almet commented 10 months ago

Thanks, that looks good to me.

aristocrates commented 10 months ago

Thanks, I also added the s/If empty/By default/ change

zorun commented 10 months ago

Thanks for catching the doc issue.

From what I remember from last time I looked at this, the default value from Flask was an empty string. We merely force this to be / in all our example configs, see 3788b6f5e75a1077f662edd660650877e9cd52e6 . But it seems I remember wrong: https://flask.palletsprojects.com/en/2.3.x/config/#APPLICATION_ROOT

By the way, this is all a hack, normally we are supposed to get this variable from the web server / runtime environment, and not define it ourselves. But anyway :)

In any case, this looks good to me!