Chemical-Curation / chemcurator_django

Backend services for chemical curation
https://api.chemreg.epa.gov
MIT License
1 stars 0 forks source link

246 image breaking ssl #268

Closed michael-barbour closed 3 years ago

michael-barbour commented 3 years ago

closes #246

This was using __BASE_SERVER__ in the jsonnet files to attempt to locate the static root. This was causing problems because the static root will not necessarily be the same as the request url + /static.

Instead the jsonnet will locate the static root on server init and will append 'openapi/logo.svg'.

Testing

To test you can navigate to {{repo_root}}/config/settings.py and change STATIC_URL. If you want to verify it's working you can also runserver on a different port and tell it to query against that port. manage.py runserver 8005 and set STATIC_URL = "http://127.0.0.1:8005/". Static requests should now hit your second server at port 8005.

I could write a test for this but it would essentially just monitor that changing this setting changes the location of the ajax request. I couldn't verify the schema/etc is correct as all I'm doing is changing how we source the static url.

debboutr commented 3 years ago

this replaces the full path, in our case something like http://127.0.0.1:8000 and replaces it with /static/ which is what our settings have namespaced to collected_static in our config/settings.py

so we had an element that looked like this...

<img src="http://127.0.0.1:8000/static/openapi/logo.svg" alt="chemreg" class="sc-kafWEX hZCbNs">

and we it will now look like this

<img src="/static/openapi/logo.svg" alt="chemreg" class="sc-kafWEX hZCbNs">

I think this should fix the problem, if not we will need to dig into the setup that we are using to serve it on Apache.