🌟 🎉 Major Update:

This commit is contained in:
2025-06-01 23:41:02 +02:00
parent 62efe03887
commit 4042f07c00
228 changed files with 8598 additions and 1893 deletions

View File

@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';
import { API_BASE_URL } from '@/utils/api-config';
/**
* Health Check Endpoint für Frontend-Server
@@ -6,8 +7,8 @@ import { NextRequest, NextResponse } from 'next/server';
*/
export async function GET(request: NextRequest) {
try {
// Prüfe Backend-Verbindung
const backendUrl = process.env.NEXT_PUBLIC_API_URL || 'https://raspberrypi';
// Bestimme die Backend-URL basierend auf der Konfiguration
const backendUrl = typeof API_BASE_URL === 'object' ? API_BASE_URL.primary : API_BASE_URL;
let backendStatus = 'unknown';
try {

View File

@@ -2,30 +2,30 @@
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
// Basis-URL für Backend-API
// Versucht verschiedene Verbindungsoptionen mit Fallbacks
// Backend läuft auf separatem Server unter https://192.168.0.105:443
const getApiBaseUrl = () => {
// Explizit gesetzte Umgebungsvariable hat höchste Priorität
if (process.env.NEXT_PUBLIC_API_URL) {
return process.env.NEXT_PUBLIC_API_URL;
}
// Im Browser: Verschiedene Verbindungsoptionen versuchen
// Primäre Backend-URL: Separater Server
const BACKEND_SERVER_URL = 'https://192.168.0.105:443';
// Im Browser: Verwende primär den separaten Backend-Server
if (typeof window !== 'undefined') {
// Primäre Verbindungsoption: HTTPS auf Port 443
const hostname = window.location.hostname === 'localhost' ? 'raspberrypi' : window.location.hostname;
// Verbindungsoptionen in Prioritätsreihenfolge
return {
primary: `https://${hostname}`,
primary: BACKEND_SERVER_URL,
fallbacks: [
`https://raspberrypi`,
`https://192.168.0.105`,
`https://192.168.0.105`, // Fallback ohne expliziten Port
`https://raspberrypi`, // Lokaler Raspberry Pi Fallback
]
};
}
// Standardwert für serverseitiges Rendering
return `https://raspberrypi`;
// Standardwert für serverseitiges Rendering: Separater Backend-Server
return BACKEND_SERVER_URL;
};
export const API_BASE_URL = getApiBaseUrl();
@@ -114,15 +114,22 @@ export const testSSLConnection = async (): Promise<boolean> => {
}
};
// Hilfsfunktion zum Erstellen vollständiger API-URLs
export const getFullApiUrl = (endpoint: string): string => {
const baseUrl = typeof API_BASE_URL === 'object' ? API_BASE_URL.primary : API_BASE_URL;
return `${baseUrl}${endpoint}`;
};
// Endpunkte für die verschiedenen Ressourcen
export const API_ENDPOINTS = {
PRINTERS: `/api/printers`,
JOBS: `/api/jobs`,
USERS: `/api/users`,
PRINTERS: getFullApiUrl(`/api/printers`),
JOBS: getFullApiUrl(`/api/jobs`),
USERS: getFullApiUrl(`/api/users`),
HEALTH: getFullApiUrl(`/health`),
// OAuth-spezifische Endpunkte
AUTH: {
LOGIN: `/api/auth/login`,
CALLBACK: `/api/auth/callback`,
LOGIN: getFullApiUrl(`/api/auth/login`),
CALLBACK: getFullApiUrl(`/api/auth/callback`),
}
};