Remove Playwright dependency and related proxy service files from the backend. This commit deletes the node-fetch package and its associated files, as well as the nuscoreProxyRoutes and nuscoreProxyService, streamlining the backend by eliminating unused components.

This commit is contained in:
Torsten Schulz (local)
2025-11-12 13:41:09 +01:00
parent 45381707ea
commit 3c64e2e92d
6 changed files with 0 additions and 1243 deletions

View File

@@ -1,139 +0,0 @@
import { chromium } from 'playwright';
class NuscoreProxyService {
constructor() {
this.browser = null;
this.context = null;
}
async initialize() {
if (!this.browser) {
this.browser = await chromium.launch({
headless: true,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-web-security',
'--disable-features=VizDisplayCompositor'
]
});
this.context = await this.browser.newContext({
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
viewport: { width: 1920, height: 1080 },
ignoreHTTPSErrors: true
});
}
}
async proxyNuscorePage(code, pin = null) {
try {
await this.initialize();
const page = await this.context.newPage();
// Navigiere direkt zur nuscore-Seite ohne Request-Interception
const nuscoreUrl = `https://ttde-apps.liga.nu/nuliga/nuscore-tt/meetings-list?code=${encodeURIComponent(code)}`;
await page.goto(nuscoreUrl, {
waitUntil: 'load',
timeout: 30000
});
// Optional: PIN automatisch einfügen falls vorhanden
if (pin) {
try {
// Suche nach PIN-Eingabefeld
const pinInput = await page.locator('input[type="password"][placeholder*="PIN"], input[placeholder*="Pin"], input[placeholder*="pin"]').first();
if (await pinInput.isVisible()) {
await pinInput.fill(pin);
// Optional: Submit-Button klicken falls vorhanden
const submitBtn = await page.locator('button[type="submit"], input[type="submit"], button:has-text("Einloggen"), button:has-text("Anmelden")').first();
if (await submitBtn.isVisible()) {
await submitBtn.click();
await page.waitForLoadState('load', { timeout: 5000 });
}
}
} catch (error) {
}
}
// HTML-Inhalt abrufen und modifizieren
const html = await page.content();
// HTML modifizieren für Proxy-Betrieb
const modifiedHtml = this.modifyHtmlForProxy(html, code);
await page.close();
return modifiedHtml;
} catch (error) {
console.error('❌ Fehler beim Proxying der nuscore-Seite:', error);
throw error;
}
}
modifyHtmlForProxy(html, code) {
// Entferne problematische Headers/Meta-Tags
let modified = html
.replace(/<meta[^>]*http-equiv=["']content-security-policy["'][^>]*>/gi, '')
.replace(/<meta[^>]*http-equiv=["']x-frame-options["'][^>]*>/gi, '')
.replace(/<meta[^>]*http-equiv=["']x-content-type-options["'][^>]*>/gi, '');
// Entferne Service Worker Registrierung (kann Probleme verursachen)
modified = modified.replace(
/navigator\.serviceWorker\.register\([^)]+\)/g,
'// Service Worker deaktiviert für Proxy'
);
return modified;
}
async proxyAsset(url) {
try {
await this.initialize();
const page = await this.context.newPage();
const response = await page.goto(url, {
waitUntil: 'networkidle',
timeout: 15000
});
if (!response || !response.ok()) {
throw new Error(`Asset nicht erreichbar: ${url}`);
}
const content = await response.body();
const contentType = response.headers()['content-type'] || 'application/octet-stream';
await page.close();
return { content, contentType };
} catch (error) {
console.error(`❌ Fehler beim Laden von Asset ${url}:`, error.message);
throw error;
}
}
async cleanup() {
if (this.context) {
await this.context.close();
this.context = null;
}
if (this.browser) {
await this.browser.close();
this.browser = null;
}
}
}
// Singleton-Instanz
const nuscoreProxyService = new NuscoreProxyService();
export default nuscoreProxyService;