aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-07-10 11:13:41 +0200
committerChocobozzz <me@florianbigard.com>2020-07-10 11:13:41 +0200
commit72493e44e9b455a04c4f093ed6c6ffa300b98d8b (patch)
treefc39d2b119ffbbf76339cf1dc2a9bd160c35c304
parent1fdf8edb77008133e80e5ab8e846b7f8fdfecf12 (diff)
downloadPeerTube-72493e44e9b455a04c4f093ed6c6ffa300b98d8b.tar.gz
PeerTube-72493e44e9b455a04c4f093ed6c6ffa300b98d8b.tar.zst
PeerTube-72493e44e9b455a04c4f093ed6c6ffa300b98d8b.zip
Fix embed url
-rw-r--r--client/src/app/helpers/utils.ts11
-rw-r--r--client/src/app/shared/shared-main/video/video.model.ts5
-rw-r--r--client/src/environments/environment.e2e.ts2
-rw-r--r--client/src/environments/environment.hmr.ts2
-rw-r--r--client/src/environments/environment.prod.ts2
-rw-r--r--client/src/environments/environment.ts2
6 files changed, 17 insertions, 7 deletions
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 () {
45 return absoluteAPIUrl 45 return absoluteAPIUrl
46} 46}
47 47
48function getAbsoluteEmbedUrl () {
49 let absoluteEmbedUrl = environment.embedUrl
50 if (!absoluteEmbedUrl) {
51 // The Embed is on the same domain
52 absoluteEmbedUrl = window.location.origin
53 }
54
55 return absoluteEmbedUrl
56}
57
48const datePipe = new DatePipe('en') 58const datePipe = new DatePipe('en')
49function dateToHuman (date: string) { 59function dateToHuman (date: string) {
50 return datePipe.transform(date, 'medium') 60 return datePipe.transform(date, 'medium')
@@ -201,6 +211,7 @@ export {
201 dateToHuman, 211 dateToHuman,
202 immutableAssign, 212 immutableAssign,
203 objectToFormData, 213 objectToFormData,
214 getAbsoluteEmbedUrl,
204 objectLineFeedToHtml, 215 objectLineFeedToHtml,
205 removeElementFromArray, 216 removeElementFromArray,
206 importModule, 217 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 @@
1import { AuthUser } from '@app/core' 1import { AuthUser } from '@app/core'
2import { User } from '@app/core/users/user.model' 2import { User } from '@app/core/users/user.model'
3import { durationToString, getAbsoluteAPIUrl } from '@app/helpers' 3import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
4import { 4import {
5 Avatar, 5 Avatar,
6 peertubeTranslate, 6 peertubeTranslate,
@@ -12,7 +12,6 @@ import {
12 VideoScheduleUpdate, 12 VideoScheduleUpdate,
13 VideoState 13 VideoState
14} from '@shared/models' 14} from '@shared/models'
15import { environment } from '../../../../environments/environment'
16import { Actor } from '../account/actor.model' 15import { Actor } from '../account/actor.model'
17 16
18export class Video implements VideoServerModel { 17export class Video implements VideoServerModel {
@@ -118,7 +117,7 @@ export class Video implements VideoServerModel {
118 this.previewUrl = hash.previewUrl || (absoluteAPIUrl + hash.previewPath) 117 this.previewUrl = hash.previewUrl || (absoluteAPIUrl + hash.previewPath)
119 118
120 this.embedPath = hash.embedPath 119 this.embedPath = hash.embedPath
121 this.embedUrl = hash.embedUrl || (environment.embedUrl + hash.embedPath) 120 this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath)
122 121
123 this.url = hash.url 122 this.url = hash.url
124 123
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 = {
2 production: false, 2 production: false,
3 hmr: false, 3 hmr: false,
4 apiUrl: 'http://localhost:9001', 4 apiUrl: 'http://localhost:9001',
5 embedUrl: 'http://localhost:9001/videos/embed' 5 embedUrl: 'http://localhost:9001'
6} 6}
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 = {
2 production: false, 2 production: false,
3 hmr: true, 3 hmr: true,
4 apiUrl: '', 4 apiUrl: '',
5 embedUrl: 'http://localhost:9000/videos/embed' 5 embedUrl: 'http://localhost:9000'
6} 6}
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 = {
2 production: true, 2 production: true,
3 hmr: false, 3 hmr: false,
4 apiUrl: '', 4 apiUrl: '',
5 embedUrl: '/videos/embed' 5 embedUrl: ''
6} 6}
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 = {
12 production: false, 12 production: false,
13 hmr: false, 13 hmr: false,
14 apiUrl: 'http://localhost:9000', 14 apiUrl: 'http://localhost:9000',
15 embedUrl: 'http://localhost:9000/videos/embed' 15 embedUrl: 'http://localhost:9000'
16} 16}