Skip to content

Commit

Permalink
fix: can't load or display Vercel Blob files
Browse files Browse the repository at this point in the history
  • Loading branch information
lfavole committed Nov 27, 2024
1 parent 55fca61 commit 5e1cab7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_info(self, name):
raise FileNotFoundError(f"The file {name} doesn't exist")

# save the prefix for later use
self._prefix = data["blobs"][0]["url"].removeprefix(name).rstrip("/").removeprefix(self.folder).rstrip("/")
self._prefix = data["blobs"][0]["url"].removesuffix(name).rstrip("/").removesuffix(self.folder).rstrip("/")
return data["blobs"][0]

def url(self, name):
Expand Down
6 changes: 6 additions & 0 deletions website/settings/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import re
from urllib.parse import quote, urlparse

from django.core.files.storage import default_storage
from django.utils.functional import lazy
from django.utils.translation import gettext_lazy as _

from .env import DEBUG, PRODUCTION, SENTRY_DSN, SENTRY_SDK
Expand Down Expand Up @@ -40,6 +42,10 @@
"https://hcaptcha.com",
"https://*.hcaptcha.com",
],
"img-src": [
"self",
lazy(lambda: getattr(default_storage, "_prefix", "")),
],
"style-src": [
"self",
"https://cdn.jsdelivr.net",
Expand Down

0 comments on commit 5e1cab7

Please sign in to comment.