mirror of
https://github.com/Eugeny/tabby-web.git
synced 2026-08-18 15:26:04 +01:00
wip
This commit is contained in:
25
frontend/src/common/services/common.service.ts
Normal file
25
frontend/src/common/services/common.service.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Inject, Injectable, Optional } from '@angular/core'
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CommonService {
|
||||
backendURL: string
|
||||
|
||||
constructor (@Inject('BACKEND_URL') @Optional() ssrBackendURL: string) {
|
||||
const tag = (document.querySelector('meta[property=x-tabby-web-backend-url]') as HTMLMetaElement)
|
||||
if (ssrBackendURL) {
|
||||
this.backendURL = ssrBackendURL
|
||||
tag.content = ssrBackendURL
|
||||
} else {
|
||||
if (tag.content && !tag.content.startsWith('{{')) {
|
||||
this.backendURL = tag.content
|
||||
} else {
|
||||
this.backendURL = ''
|
||||
}
|
||||
}
|
||||
|
||||
console.log(this.backendURL)
|
||||
if (this.backendURL.endsWith('/')) {
|
||||
this.backendURL = this.backendURL.slice(0, -1)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user