pull/3895/head
TidusJar 6 years ago
parent 6926feb9ed
commit 0ad8eccbdf

@ -83,9 +83,8 @@ export function HttpLoaderFactory(http: HttpClient, platformLocation: PlatformLo
}
return new TranslateHttpLoader(http, "/translations/", `.json?v=${version}`);
}
export function baseurlFact() {
return "/" + window['_app_base'];
return "/" + localStorage.getItem("baseUrl");
}
export function JwtTokenGetter() {
@ -171,12 +170,11 @@ export function JwtTokenGetter() {
IssuesService,
PlexTvService,
SearchService,
SearchV2Service,
SearchV2Service,
{
provide: APP_BASE_HREF,
useFactory: baseurlFact
}
],
} ],
bootstrap: [AppComponent],
})
export class AppModule { }

@ -3,29 +3,41 @@
<head>
<script>
const existingBaseUrl = window.localStorage.getItem("baseUrl");
if (existingBaseUrl) {
document.write('<base href="/' + existingBaseUrl + '" />');
} else {
// Work out the base URL
// Need to find the baseUrl.txt file
const url = window.location.href;
let hasFile = false;
fetch(url + "/baseUrl.json")
.then(response => {
return response.json();
}).then(data => {
this.hasFile = true;
document.write('<base href="/' + data.baseUrl + '" />');
window.localStorage.setItem("baseUrl", data.baseUrl);
}).catch(err => {
console.error(err);
});
}
</script>
<script>
// TODO change to fetch and reload page
const existingBaseUrl = window.localStorage.getItem("baseUrl");
if (existingBaseUrl) {
document.write('<base href="/' + existingBaseUrl + '" />');
} else {
// Work out the base URL
// Need to find the baseUrl.txt file
let url = window.location.href;
var xmlhttp = new XMLHttpRequest();
debugger;
xmlhttp.open("GET", url + "api/v1/Settings/baseurl", false);
xmlhttp.send();
while (xmlhttp.status === 404) {
// try again
url = url.slice(0, url.lastIndexOf("/"));
tryGetBaseUrl(xmlhttp, url);
}
const data = JSON.parse(xmlhttp.responseText);
debugger;
document.write('<base href="/' + data + '" />');
window.localStorage.setItem("baseUrl", data);
function tryGetBaseUrl(xmlhttp, url) {
debugger;
xmlhttp.open("GET", url + "/api/v1/Settings/baseurl", false);
xmlhttp.send();
}
}
</script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

Loading…
Cancel
Save