From 8418b26d702180d84df9adaf728b9ac1c3b4a3c6 Mon Sep 17 00:00:00 2001 From: Roger Far Date: Sun, 11 Jun 2023 12:31:13 -0600 Subject: [PATCH] Add option to set the base href. --- client/src/app/auth.service.ts | 17 +++--- client/src/app/login/login.component.html | 2 +- client/src/app/navbar/navbar.component.html | 2 +- client/src/app/settings.service.ts | 19 +++---- client/src/app/setup/setup.component.html | 8 +-- client/src/app/torrent.service.ts | 30 ++++++----- client/src/index.html | 3 +- .../Models/Internal/AppSettings.cs | 1 + .../Middleware/BaseHrefMiddleware.cs | 54 +++++++++++++++++++ server/RdtClient.Web/Program.cs | 5 ++ .../Properties/launchSettings.json | 2 +- server/RdtClient.Web/appsettings.json | 3 +- 12 files changed, 107 insertions(+), 39 deletions(-) create mode 100644 server/RdtClient.Service/Middleware/BaseHrefMiddleware.cs diff --git a/client/src/app/auth.service.ts b/client/src/app/auth.service.ts index 56d5a39..47e5b76 100644 --- a/client/src/app/auth.service.ts +++ b/client/src/app/auth.service.ts @@ -1,44 +1,45 @@ +import { APP_BASE_HREF } from '@angular/common'; import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Inject, Injectable } from '@angular/core'; import { Observable } from 'rxjs/internal/Observable'; @Injectable({ providedIn: 'root', }) export class AuthService { - constructor(private http: HttpClient) {} + constructor(private http: HttpClient, @Inject(APP_BASE_HREF) private baseHref: string) {} public isLoggedIn(): Observable { - return this.http.get(`/Api/Authentication/IsLoggedIn`); + return this.http.get(`${this.baseHref}Api/Authentication/IsLoggedIn`); } public create(userName: string, password: string): Observable { - return this.http.post(`/Api/Authentication/Create`, { + return this.http.post(`${this.baseHref}Api/Authentication/Create`, { userName, password, }); } public setupProvider(provider: string, token: string): Observable { - return this.http.post(`/Api/Authentication/SetupProvider`, { + return this.http.post(`${this.baseHref}Api/Authentication/SetupProvider`, { provider, token, }); } public login(userName: string, password: string): Observable { - return this.http.post(`/Api/Authentication/Login`, { + return this.http.post(`${this.baseHref}Api/Authentication/Login`, { userName, password, }); } public logout() { - return this.http.post(`/Api/Authentication/Logout`, {}); + return this.http.post(`${this.baseHref}Api/Authentication/Logout`, {}); } public update(userName: string, password: string): Observable { - return this.http.post(`/Api/Authentication/Update`, { + return this.http.post(`${this.baseHref}Api/Authentication/Update`, { userName, password, }); diff --git a/client/src/app/login/login.component.html b/client/src/app/login/login.component.html index 465b3a4..87fcb3f 100644 --- a/client/src/app/login/login.component.html +++ b/client/src/app/login/login.component.html @@ -3,7 +3,7 @@
- +
diff --git a/client/src/app/navbar/navbar.component.html b/client/src/app/navbar/navbar.component.html index 69f3e49..b944756 100644 --- a/client/src/app/navbar/navbar.component.html +++ b/client/src/app/navbar/navbar.component.html @@ -1,7 +1,7 @@