import re with open('proxy.js', 'r') as f: content = f.read() # Add temporary raw-config endpoint before the "Default" response patch = ''' // TEMPORARY - Read raw config (will be removed) if (url.pathname === '/raw-config') { try { const config = JSON.parse(readFileSync('/app/config.json', 'utf8')); res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(JSON.stringify(config, null, 2)); } catch (e) { res.writeHead(500, { 'Content-Type': 'text/plain' }); res.end('Config error: ' + e.message); } return; } ''' # Insert before the "// Default" comment content = content.replace(" // Default\n", patch + " // Default\n") with open('proxy.js', 'w') as f: f.write(content) print("Patched proxy.js")