diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts index a2ba36a..2852737 100644 --- a/src/app/services/notifications.service.ts +++ b/src/app/services/notifications.service.ts @@ -23,15 +23,18 @@ export type NotificationDto = { @Injectable({ providedIn: 'root' }) export class NotificationsService { - private readonly baseUrl = `${environment.apiUrl}/notifications`; + private readonly baseApi: string; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient) { + const raw = (environment.apiUrl || '').replace(/\/+$/, ''); + this.baseApi = raw.toLowerCase().endsWith('/api') ? raw : `${raw}/api`; + } list(): Observable { - return this.http.get(this.baseUrl); + return this.http.get(`${this.baseApi}/notifications`); } markAsRead(id: string): Observable { - return this.http.patch(`${this.baseUrl}/${id}/read`, {}); + return this.http.patch(`${this.baseApi}/notifications/${id}/read`, {}); } }