-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper to get only the hostname out of MEDIA_URL (#14723)
settings.MEDIA_URL (passed in here as media_url) is a custom route on our CDN that points to a cloud bucket, which we use for uploaded media from the CMS. Specifically, due to infra constraints, it has to point to a _sub-path_ in the bucket, not the top/root of it. It also needs to be distinct from the CDN route that points to our collected static assets (which are at https://<CDN_HOSTNAME>/media/ - that is STATIC_URL) With all this in mind, MEDIA_URL, when set, points to https://<CDN_HOSTNAME>/media/cms/ When django-storages computes the URL for a object in that CMS bucket, it wants just the hostname of the bucket, not the full CDN/proxy path to the subdir in the bucket, because it opinionatedly concatenates it with GS_LOCATION (which is needed to ensure the files are uploaded to the sub-path mentioned above). TLDR: We just need the root of the CDN, from MEDIA_URL.
- Loading branch information
1 parent
0c04c6a
commit 71a92e9
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters