Directus API-Key aus Code entfernen

This commit is contained in:
2026-06-24 13:04:40 +02:00
parent 621b98a8c5
commit d0ac5f2737
4 changed files with 17 additions and 21 deletions
+9 -18
View File
@@ -1,29 +1,20 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Links } from './links';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import * as _ from 'lodash'; import { LinksResponse } from './links'; // ← Import ergänzen
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class LinksService { export class LinksService {
private apiUrl = 'http://directus.neugasse.lan/items/landingpage';
httpOptions = {};
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
private apiUrl = 'http://directus.neugasse.lan/items/landingpage';
public apiKey = 'KGjpxZ3tesmhEXHS7C7JbKDyW6YJlgQT';
httpOptions = { getLinks(): Observable<LinksResponse> { // ← doppeltes g entfernt
headers: new HttpHeaders({ return this.http.get<LinksResponse>(this.apiUrl);
'Authorization': `Bearer ${this.apiKey}`, }
}),
};
getLinks(): Observable<Links> {
return this.http
.get<Links>(this.apiUrl, this.httpOptions)
}
} }
+5
View File
@@ -6,3 +6,8 @@ export interface Links {
link: string; link: string;
link_zu_software: string link_zu_software: string
} }
export type LinkItem = Links; // ← Alias, kein Breaking Change
export interface LinksResponse {
data: LinkItem[];
}
+1 -1
View File
@@ -5,7 +5,7 @@
{{ link.name }} {{ link.name }}
</h4> </h4>
<a href="{{ link.link }}" target="_blank" class="card-link"> <a href="{{ link.link }}" target="_blank" class="card-link">
<img src="http://10.0.0.104:8055/assets/{{ link.bild }}?access_token={{ apiKey }}&width=200" alt=" {{ link.name }}" style="width:100px" > <img src="/api/assets/{{ link.bild }}?width=200" alt="{{ link.name }}" style="width:100px">" style="width:100px" >
</a> </a>
<div class="card-body"> <div class="card-body">
<p class="card-text">{{ link.beschreibung }}</p> <p class="card-text">{{ link.beschreibung }}</p>
+2 -2
View File
@@ -10,7 +10,7 @@ import { Subscription } from 'rxjs';
export class LinksComponent implements OnInit { export class LinksComponent implements OnInit {
linkList: any = []; linkList: any = [];
apiKey = this.linkservice.apiKey; //apiKey = this.linkservice.apiKey;
constructor (public linkservice: LinksService) {} constructor (public linkservice: LinksService) {}
@@ -21,7 +21,7 @@ export class LinksComponent implements OnInit {
getLinks() { getLinks() {
return this.linkservice.getLinks().subscribe((data: any) => { return this.linkservice.getLinks().subscribe((data: any) => {
this.linkList = data.data; this.linkList = data.data;
this.apiKey; //this.apiKey;
console.log(this.linkList); console.log(this.linkList);
}); });