- Added SSL configuration to the backend, including self-signed certificate generation and management. - Updated `setup_myp.sh` to create SSL certificates during installation. - Enhanced `app.py` to support SSL context for secure communication. - Introduced a new SSL management menu in the setup script for easier certificate handling. - Updated frontend API calls to use HTTPS for secure data transmission. - Implemented kiosk mode features, including automatic browser launch with SSL support. - Improved documentation in `SUMMARY.md` to reflect new features and network topology changes.
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { API_BASE_URL } from './api-config';
|
|
|
|
/**
|
|
* ExternalAPI - Wrapper für externe API-Aufrufe mit HTTPS-Unterstützung
|
|
* Enthält Logik für Offline-Fallback und Behandlung von selbstsignierten Zertifikaten
|
|
*/
|
|
export class ExternalAPI {
|
|
private baseURL: string;
|
|
|
|
constructor() {
|
|
this.baseURL = API_BASE_URL;
|
|
}
|
|
|
|
/**
|
|
* Führt einen API-Request durch mit Unterstützung für selbstsignierte Zertifikate
|
|
* im Entwicklungsmodus
|
|
*/
|
|
async fetch<T>(endpoint: string, options: RequestInit = {}): Promise<T> {
|
|
const url = `${this.baseURL}${endpoint}`;
|
|
|
|
try {
|
|
const response = await fetch(url, {
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers,
|
|
},
|
|
// Im Browser werden selbstsignierte Zertifikate über die Browser-Einstellungen akzeptiert
|
|
// Die fetch API im Browser hat keine Option zum Ignorieren von Zertifikaten
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`API Error: ${response.status}`);
|
|
}
|
|
|
|
return await response.json();
|
|
} catch (error) {
|
|
console.error('API Fehler:', error);
|
|
|
|
// Prüfen auf Zertifikatsfehler
|
|
if (error instanceof Error && error.message.includes('certificate')) {
|
|
console.warn('Zertifikatsfehler: Bitte akzeptieren Sie das selbstsignierte Zertifikat manuell, indem Sie direkt auf https://192.168.0.105:5000 zugreifen und es bestätigen.');
|
|
}
|
|
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
// API-Methoden für verschiedene Endpoints
|
|
async getPrinters() {
|
|
return this.fetch<any>('/api/printers');
|
|
}
|
|
|
|
async getJobs() {
|
|
return this.fetch<any>('/api/jobs');
|
|
}
|
|
} |