From 72493e44e9b455a04c4f093ed6c6ffa300b98d8b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 10 Jul 2020 11:13:41 +0200 Subject: Fix embed url --- client/src/app/helpers/utils.ts | 11 +++++++++++ client/src/app/shared/shared-main/video/video.model.ts | 5 ++--- client/src/environments/environment.e2e.ts | 2 +- client/src/environments/environment.hmr.ts | 2 +- client/src/environments/environment.prod.ts | 2 +- client/src/environments/environment.ts | 2 +- 6 files changed, 17 insertions(+), 7 deletions(-) (limited to 'client/src') diff --git a/client/src/app/helpers/utils.ts b/client/src/app/helpers/utils.ts index 879f697f4..9bf22f62f 100644 --- a/client/src/app/helpers/utils.ts +++ b/client/src/app/helpers/utils.ts @@ -45,6 +45,16 @@ function getAbsoluteAPIUrl () { return absoluteAPIUrl } +function getAbsoluteEmbedUrl () { + let absoluteEmbedUrl = environment.embedUrl + if (!absoluteEmbedUrl) { + // The Embed is on the same domain + absoluteEmbedUrl = window.location.origin + } + + return absoluteEmbedUrl +} + const datePipe = new DatePipe('en') function dateToHuman (date: string) { return datePipe.transform(date, 'medium') @@ -201,6 +211,7 @@ export { dateToHuman, immutableAssign, objectToFormData, + getAbsoluteEmbedUrl, objectLineFeedToHtml, removeElementFromArray, importModule, diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts index 3e6d6a38d..147d0817e 100644 --- a/client/src/app/shared/shared-main/video/video.model.ts +++ b/client/src/app/shared/shared-main/video/video.model.ts @@ -1,6 +1,6 @@ import { AuthUser } from '@app/core' import { User } from '@app/core/users/user.model' -import { durationToString, getAbsoluteAPIUrl } from '@app/helpers' +import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers' import { Avatar, peertubeTranslate, @@ -12,7 +12,6 @@ import { VideoScheduleUpdate, VideoState } from '@shared/models' -import { environment } from '../../../../environments/environment' import { Actor } from '../account/actor.model' export class Video implements VideoServerModel { @@ -118,7 +117,7 @@ export class Video implements VideoServerModel { this.previewUrl = hash.previewUrl || (absoluteAPIUrl + hash.previewPath) this.embedPath = hash.embedPath - this.embedUrl = hash.embedUrl || (environment.embedUrl + hash.embedPath) + this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath) this.url = hash.url diff --git a/client/src/environments/environment.e2e.ts b/client/src/environments/environment.e2e.ts index 7724d27c9..b33ff9f86 100644 --- a/client/src/environments/environment.e2e.ts +++ b/client/src/environments/environment.e2e.ts @@ -2,5 +2,5 @@ export const environment = { production: false, hmr: false, apiUrl: 'http://localhost:9001', - embedUrl: 'http://localhost:9001/videos/embed' + embedUrl: 'http://localhost:9001' } diff --git a/client/src/environments/environment.hmr.ts b/client/src/environments/environment.hmr.ts index 72eed45e5..3b6eff302 100644 --- a/client/src/environments/environment.hmr.ts +++ b/client/src/environments/environment.hmr.ts @@ -2,5 +2,5 @@ export const environment = { production: false, hmr: true, apiUrl: '', - embedUrl: 'http://localhost:9000/videos/embed' + embedUrl: 'http://localhost:9000' } diff --git a/client/src/environments/environment.prod.ts b/client/src/environments/environment.prod.ts index 368aa1389..2e9b9fefe 100644 --- a/client/src/environments/environment.prod.ts +++ b/client/src/environments/environment.prod.ts @@ -2,5 +2,5 @@ export const environment = { production: true, hmr: false, apiUrl: '', - embedUrl: '/videos/embed' + embedUrl: '' } diff --git a/client/src/environments/environment.ts b/client/src/environments/environment.ts index 60f5d9450..4816e3060 100644 --- a/client/src/environments/environment.ts +++ b/client/src/environments/environment.ts @@ -12,5 +12,5 @@ export const environment = { production: false, hmr: false, apiUrl: 'http://localhost:9000', - embedUrl: 'http://localhost:9000/videos/embed' + embedUrl: 'http://localhost:9000' } -- cgit v1.2.3