File size: 808 Bytes
cde5d07
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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")