From e7422d8845c981a86d6a9017fcd1130406a453f3 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Fri, 7 Jun 2019 22:44:27 +0100 Subject: [PATCH] Fixed the SignalR notification base url --- src/Ombi/ClientApp/src/app/app.module.ts | 2 +- .../services/signlarnotification.service.ts | 12 ++++-- src/Ombi/ClientApp/src/index.html | 42 ++----------------- 3 files changed, 13 insertions(+), 43 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/app.module.ts b/src/Ombi/ClientApp/src/app/app.module.ts index e06740d9a..7069bd062 100644 --- a/src/Ombi/ClientApp/src/app/app.module.ts +++ b/src/Ombi/ClientApp/src/app/app.module.ts @@ -83,7 +83,7 @@ const routes: Routes = [ // AoT requires an exported function for factories export function HttpLoaderFactory(http: HttpClient, platformLocation: PlatformLocation) { // const base = getBaseLocation(); - const base = '/' + (window.location.pathname.split('/')[1] || '') + const base = platformLocation.getBaseHrefFromDOM(); const version = Math.floor(Math.random() * 999999999); if (base !== null && base.length > 1) { return new TranslateHttpLoader(http, `${base}/translations/`, `.json?v=${version}`); diff --git a/src/Ombi/ClientApp/src/app/services/signlarnotification.service.ts b/src/Ombi/ClientApp/src/app/services/signlarnotification.service.ts index 92ec7e3dc..ea4c4691c 100644 --- a/src/Ombi/ClientApp/src/app/services/signlarnotification.service.ts +++ b/src/Ombi/ClientApp/src/app/services/signlarnotification.service.ts @@ -3,6 +3,8 @@ import { AuthService } from '../auth/auth.service'; import { HubConnection } from '@aspnet/signalr'; import * as signalR from '@aspnet/signalr'; +import { PlatformLocation } from '@angular/common'; +import { platformBrowser } from '@angular/platform-browser'; @Injectable() export class SignalRNotificationService { @@ -10,15 +12,19 @@ export class SignalRNotificationService { private hubConnection: HubConnection | undefined; public Notification: EventEmitter; - constructor(private authService: AuthService) { + constructor(private authService: AuthService, private platform: PlatformLocation) { this.Notification = new EventEmitter(); } public initialize(): void { this.stopConnection(); - - this.hubConnection = new signalR.HubConnectionBuilder().withUrl("/hubs/notification", { + let url = "/hubs/notification"; + const baseUrl = this.platform.getBaseHrefFromDOM(); + if(baseUrl !== null && baseUrl.length > 1) { + url = baseUrl + url; + } + this.hubConnection = new signalR.HubConnectionBuilder().withUrl(url, { accessTokenFactory: () => { return this.authService.getToken(); } diff --git a/src/Ombi/ClientApp/src/index.html b/src/Ombi/ClientApp/src/index.html index 679997c40..874a5a595 100644 --- a/src/Ombi/ClientApp/src/index.html +++ b/src/Ombi/ClientApp/src/index.html @@ -3,45 +3,9 @@