Skip to content

Commit

Permalink
fix: Fix bug in https protocol (prod env)
Browse files Browse the repository at this point in the history
  • Loading branch information
drorganvidez committed Aug 29, 2024
1 parent be71660 commit 7776e13
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/modules/hubfile/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ def to_dict(self):
flask_env = os.getenv('FLASK_ENV', 'development')
domain = os.getenv('DOMAIN', 'localhost')

# If the domain looks like a subdomain (contains more than one dot), do not add ‘www’.
if domain.count('.') == 1:
domain = f"www.{domain}"

# If in production, use https, otherwise use http
protocol = 'https' if flask_env == 'production' else 'http'

# Construct the URL using the appropriate protocol and domain.
url = f"{protocol}://www.{domain}/hubfile/download/{self.id}"
url = f"{protocol}://{domain}/hubfile/download/{self.id}"

return {
"id": self.id,
Expand Down

0 comments on commit 7776e13

Please sign in to comment.