mathics-django icon indicating copy to clipboard operation
mathics-django copied to clipboard

Service /media/ urls from a relative not absolute URL

Open adamboutcher opened this issue 9 months ago • 4 comments

The media files are all defined using absolute URL and not relative which causes issues if trying to service the app through a proxy.

adamboutcher avatar Feb 13 '25 13:02 adamboutcher

So I understand the need for the scripts to use absolute URLs so they serve correctly if you're using subdirs for fuctions etc

settings.py

BASE_URL = os.environ.get("MATHICS_DJANGO_URL", None
STATIC_URL = BASE_URL+"/media/"

urls.py:

re_path(r"^"+settings.BASE_URL, include("mathics_django.web.urls")),

adamboutcher avatar Feb 13 '25 13:02 adamboutcher

Ok - please work this up into a PR.

A shorter way to write the last 4 lines is:

STATIC_URL = status_url+"/media" if static_url is None else "/media"

rocky avatar Feb 13 '25 14:02 rocky

Ok - please work this up into a PR.

A shorter way to write the last 4 lines is:

STATIC_URL = status_url+"/media" if static_url is None else "/media"

My original post didnt reliably work I have however edited this.

adamboutcher avatar Feb 13 '25 14:02 adamboutcher

Ok - please work this up into a PR. A shorter way to write the last 4 lines is: STATIC_URL = status_url+"/media" if static_url is None else "/media"

My original post didnt reliably work I have however edited this.

Ok. Good to hear. If you want to get the change into the code base, please put in a PR when you can.

You are in the best position to test whether things work. What I can do is verify that it doesn't break the behavior I use.

rocky avatar Feb 13 '25 14:02 rocky

FYI I've PR'd some additional changes.

adamboutcher avatar Jul 28 '25 19:07 adamboutcher

These changes have been deployed locally for few a few months to our users and we've had no complaints, I would consider this issue resolved. If anyone does have a bug relating to these changes then please hit me up.

adamboutcher avatar Jul 28 '25 20:07 adamboutcher