]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix embed url
authorChocobozzz <me@florianbigard.com>
Fri, 10 Jul 2020 09:13:41 +0000 (11:13 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 10 Jul 2020 09:13:41 +0000 (11:13 +0200)
client/src/app/helpers/utils.ts
client/src/app/shared/shared-main/video/video.model.ts
client/src/environments/environment.e2e.ts
client/src/environments/environment.hmr.ts
client/src/environments/environment.prod.ts
client/src/environments/environment.ts

index 879f697f473370399837fdd0eadaca6c4907a163..9bf22f62f92309122bcb84051694923e3de7f2fd 100644 (file)
@@ -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,
index 3e6d6a38d6422e1cfe0eb208adc81b818cb7cb85..147d0817e2b6aba7cf300300ea0b94f55c20ee53 100644 (file)
@@ -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
 
index 7724d27c92993eae622fd4a3d1e34eadbcef04e3..b33ff9f8633cecfc7f0c4901e8e516ed8a51c394 100644 (file)
@@ -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'
 }
index 72eed45e5e6e8d7c81427c75bbbdfdaeae37c785..3b6eff302c0ce0070225c32dd02f6680bceb4942 100644 (file)
@@ -2,5 +2,5 @@ export const environment = {
   production: false,
   hmr: true,
   apiUrl: '',
-  embedUrl: 'http://localhost:9000/videos/embed'
+  embedUrl: 'http://localhost:9000'
 }
index 368aa1389907d2d15d72f32aca57679338917156..2e9b9fefebc6caed54d7cf9f3ed191fd70892242 100644 (file)
@@ -2,5 +2,5 @@ export const environment = {
   production: true,
   hmr: false,
   apiUrl: '',
-  embedUrl: '/videos/embed'
+  embedUrl: ''
 }
index 60f5d9450980cb49d8e0ec4b9cb2c0214957d684..4816e30608142c5fd130b6fbc021b7eec2ddaad3 100644 (file)
@@ -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'
 }