1
0
Fork 0

Fix embed url

This commit is contained in:
Chocobozzz 2020-07-10 11:13:41 +02:00
parent 1fdf8edb77
commit 72493e44e9
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 17 additions and 7 deletions

View File

@ -45,6 +45,16 @@ function getAbsoluteAPIUrl () {
return absoluteAPIUrl 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') const datePipe = new DatePipe('en')
function dateToHuman (date: string) { function dateToHuman (date: string) {
return datePipe.transform(date, 'medium') return datePipe.transform(date, 'medium')
@ -201,6 +211,7 @@ export {
dateToHuman, dateToHuman,
immutableAssign, immutableAssign,
objectToFormData, objectToFormData,
getAbsoluteEmbedUrl,
objectLineFeedToHtml, objectLineFeedToHtml,
removeElementFromArray, removeElementFromArray,
importModule, importModule,

View File

@ -1,6 +1,6 @@
import { AuthUser } from '@app/core' import { AuthUser } from '@app/core'
import { User } from '@app/core/users/user.model' import { User } from '@app/core/users/user.model'
import { durationToString, getAbsoluteAPIUrl } from '@app/helpers' import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
import { import {
Avatar, Avatar,
peertubeTranslate, peertubeTranslate,
@ -12,7 +12,6 @@ import {
VideoScheduleUpdate, VideoScheduleUpdate,
VideoState VideoState
} from '@shared/models' } from '@shared/models'
import { environment } from '../../../../environments/environment'
import { Actor } from '../account/actor.model' import { Actor } from '../account/actor.model'
export class Video implements VideoServerModel { export class Video implements VideoServerModel {
@ -118,7 +117,7 @@ export class Video implements VideoServerModel {
this.previewUrl = hash.previewUrl || (absoluteAPIUrl + hash.previewPath) this.previewUrl = hash.previewUrl || (absoluteAPIUrl + hash.previewPath)
this.embedPath = hash.embedPath this.embedPath = hash.embedPath
this.embedUrl = hash.embedUrl || (environment.embedUrl + hash.embedPath) this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath)
this.url = hash.url this.url = hash.url

View File

@ -2,5 +2,5 @@ export const environment = {
production: false, production: false,
hmr: false, hmr: false,
apiUrl: 'http://localhost:9001', apiUrl: 'http://localhost:9001',
embedUrl: 'http://localhost:9001/videos/embed' embedUrl: 'http://localhost:9001'
} }

View File

@ -2,5 +2,5 @@ export const environment = {
production: false, production: false,
hmr: true, hmr: true,
apiUrl: '', apiUrl: '',
embedUrl: 'http://localhost:9000/videos/embed' embedUrl: 'http://localhost:9000'
} }

View File

@ -2,5 +2,5 @@ export const environment = {
production: true, production: true,
hmr: false, hmr: false,
apiUrl: '', apiUrl: '',
embedUrl: '/videos/embed' embedUrl: ''
} }

View File

@ -12,5 +12,5 @@ export const environment = {
production: false, production: false,
hmr: false, hmr: false,
apiUrl: 'http://localhost:9000', apiUrl: 'http://localhost:9000',
embedUrl: 'http://localhost:9000/videos/embed' embedUrl: 'http://localhost:9000'
} }