ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix object storage URL generation
Chocobozzz00987ae1aa9e
diff --git a/server/core/lib/object-storage/urls.ts b/server/core/lib/object-storage/urls.tsindex 3e986c4596..4ccd8c51ac 100644--- a/server/core/lib/object-storage/urls.ts+++ b/server/core/lib/object-storage/urls.ts@@ -27,30 +27,9 @@ export function buildObjectStorageWebVideoPrivateFileUrl (filename: string) {// Private// ----------------------------------------------------------------------------let baseUrl: stringfunction buildBaseUrl (bucketInfo: BucketInfo) {- if (baseUrl) return baseUrl-- baseUrl = _buildBaseUrl(bucketInfo)-- return baseUrl-}--function _buildBaseUrl (bucketInfo: BucketInfo) {- let endpointParsed: URL-- try {- endpointParsed = new URL(getEndpoint())- } catch (error) {- logger.error(- `Invalid object storage endpoint URL: ${getEndpoint()}. ` +- `If you enabled object storage, ensure object_storage.endpoint is correctly configured. ` +- `Otherwise, check that you have correctly moved all your videos to your local filesystem.`,- lTags()- )-- return ''- }+ const endpointParsed = getEndpointParsed()+ if (!endpointParsed) return ''let baseUrlConfig = bucketInfo.BASE_URLif (baseUrlConfig && !baseUrlConfig.endsWith('/')) baseUrlConfig += '/'@@ -65,3 +44,24 @@ function _buildBaseUrl (bucketInfo: BucketInfo) {return `${endpointParsed.protocol}//${bucketInfo.BUCKET_NAME}.${endpointParsed.host}/`}++let endpointParsed: URL++function getEndpointParsed () {+ if (!endpointParsed) {+ try {+ endpointParsed = new URL(getEndpoint())+ } catch (error) {+ logger.error(+ `Invalid object storage endpoint URL: ${getEndpoint()}. ` ++ `If you enabled object storage, ensure object_storage.endpoint is correctly configured. ` ++ `Otherwise, check that you have correctly moved all your videos to your local filesystem.`,+ lTags()+ )++ return undefined+ }+ }++ return endpointParsed+}