Skip to content

Commit

Permalink
Merge pull request Hubs-Foundation#5103 from mozilla/qa-stage
Browse files Browse the repository at this point in the history
Cloudflare hubs cloud hotfix into master branch
  • Loading branch information
robinkwilson authored Feb 9, 2022
2 parents cc4a0ed + 9b891f4 commit 39835f3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/utils/phoenix-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ export function getReticulumFetchUrl(path, absolute = false, host = null, port =
}

export function getUploadsUrl(path, absolute = false, host = null, port = null) {
return configs.UPLOADS_HOST
? `https://${configs.UPLOADS_HOST}${port ? `:${port}` : ""}${path}`
// If the Hubs Cloud stack is configured to use Cloudflare, we need to ignore the configured UPLOADS_HOST
// since reticulum will only serve uploads via the Cloudflare worker. BASE_ASSETS_PATH will have been
// correctly configured to use the Cloudflare worker, though we only need the hostname,
// not the full assets URL.
const isUsingCloudflare = configs.BASE_ASSETS_PATH.includes("workers.dev");
const uploadsHost = isUsingCloudflare ? new URL(configs.BASE_ASSETS_PATH).hostname : configs.UPLOADS_HOST;
return uploadsHost
? `https://${uploadsHost}${port ? `:${port}` : ""}${path}`
: getReticulumFetchUrl(path, absolute, host, port);
}

Expand Down

0 comments on commit 39835f3

Please sign in to comment.