try a different way of the reverse proxy

pull/3895/head
Jamie Rees 6 years ago
parent 4baff16d07
commit 91e1db06f2

@ -1,41 +1,27 @@
{ {
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": ".NET Core Launch", "name": "ng serve",
"type": "coreclr", "type": "chrome",
"request": "launch", "request": "launch",
"preLaunchTask": "build", "preLaunchTask": "npm: start",
"program": "${workspaceRoot}/bin/Debug/netcoreapp2.0/Ombi.dll", "url": "http://localhost:3578/",
"args": [], "webRoot": "${workspaceFolder}"
"cwd": "${workspaceRoot}", },
"stopAtEntry": false, {
"launchBrowser": { "name": "ng test",
"enabled": true, "type": "chrome",
"args": "${auto-detect-url}", "request": "launch",
"windows": { "url": "http://localhost:9876/debug.html",
"command": "cmd.exe", "webRoot": "${workspaceFolder}",
"args": "/C start ${auto-detect-url}" "sourceMaps": true,
}, "sourceMapPathOverrides": {
"osx": { "/./*": "${webRoot}/*",
"command": "open" "/src/*": "${webRoot}/*",
}, "/*": "*",
"linux": { "/./~/*": "${webRoot}/node_modules/*"
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceRoot}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
} }
},
] ]
} }

@ -79,8 +79,9 @@ const routes: Routes = [
]; ];
// AoT requires an exported function for factories // AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient) { export function HttpLoaderFactory(http: HttpClient, platformLocation: PlatformLocation) {
const base = getBaseLocation(); // const base = getBaseLocation();
const base = platformLocation.getBaseHrefFromDOM();
const version = Math.floor(Math.random() * 999999999); const version = Math.floor(Math.random() * 999999999);
if (base.length > 1) { if (base.length > 1) {
return new TranslateHttpLoader(http, `${base}/translations/`, `.json?v=${version}`); return new TranslateHttpLoader(http, `${base}/translations/`, `.json?v=${version}`);
@ -175,10 +176,11 @@ export function JwtTokenGetter() {
SearchService, SearchService,
SearchV2Service, SearchV2Service,
MessageService, MessageService,
{ { provide: APP_BASE_HREF, useValue: window['_app_base'] || '/' }
provide: APP_BASE_HREF, // {
useFactory: getBaseLocation // provide: APP_BASE_HREF,
} // useFactory: getBaseLocation
// }
], ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
}) })

@ -2,53 +2,26 @@
<html lang="en"> <html lang="en">
<head> <head>
<script>
<!-- <script> // manually sets the <base> tag's href attribute so the app can be located in places other than root
debugger;
const existingBaseUrl = window.localStorage.getItem("baseUrl"); var split = location.pathname.split('/');
if (existingBaseUrl && existingBaseUrl.length === 0) { var base = "";
document.write('<base href="/' + existingBaseUrl + '" />'); for (var i = 0; i < split.length - 1; i++) {
if (existingBaseUrl.length === 0) { base += split[i];
document.write("<link rel=\"stylesheet\" href='/loading.css' />") if(base.length > 1) {
} else { break;
document.write("<link rel=\"stylesheet\" href='" + existingBaseUrl + "/loading.css' />")
}
} else {
// Work out the base URL
// Need to find the baseUrl.txt file
let url = window.location.href;
let hasFile = false;
var xmlhttp = new XMLHttpRequest();
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);
hasFile = true;
document.write('<base href="/' + data + '" />');
document.write("<link rel=\"stylesheet\" href='" + data + "/loading.css' />")
window.localStorage.setItem("baseUrl", data);
function tryGetBaseUrl(xmlhttp, url) {
if (endsWith(url, "/")) {
xmlhttp.open("GET", url + "api/v1/Settings/baseurl", false);
} else {
xmlhttp.open("GET", url + "/api/v1/Settings/baseurl", false);
} }
if (i < split.length - 2) {
xmlhttp.send(); base += "/";
} }
}
function endsWith(str, suffix) { if(base === "") {
return str.indexOf(suffix, str.length - suffix.length) !== -1; base = "./";
}
} }
</script> --> window['_app_base'] = base;
document.write("<base href='" + base + "' />");
</script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <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 charset="utf-8" />

Loading…
Cancel
Save