Add proxy client and route downloads through it

This commit is contained in:
AMIAY
2026-02-01 17:23:00 +01:00
parent fc91560acb
commit cd25f124bd
5 changed files with 127 additions and 42 deletions

View File

@@ -1,6 +1,7 @@
const fs = require('fs');
const path = require('path');
const { downloadFile, findHomePageUIPath, findLogoPath } = require('../utils/fileManager');
const { proxyRequest } = require('../utils/proxyClient');
async function downloadAndReplaceHomePageUI(gameDir, progressCallback) {
try {
@@ -13,7 +14,8 @@ async function downloadAndReplaceHomePageUI(gameDir, progressCallback) {
const homeUIUrl = 'https://files.hytalef2p.com/api/HomeUI';
const tempHomePath = path.join(path.dirname(gameDir), 'HomePage_temp.ui');
await downloadFile(homeUIUrl, tempHomePath);
const response = await proxyRequest(homeUIUrl, { responseType: 'arraybuffer' });
fs.writeFileSync(tempHomePath, response.data);
const existingHomePath = findHomePageUIPath(gameDir);
@@ -66,7 +68,8 @@ async function downloadAndReplaceLogo(gameDir, progressCallback) {
const logoUrl = 'https://files.hytalef2p.com/api/Logo';
const tempLogoPath = path.join(path.dirname(gameDir), 'Logo@2x_temp.png');
await downloadFile(logoUrl, tempLogoPath);
const response = await proxyRequest(logoUrl, { responseType: 'arraybuffer' });
fs.writeFileSync(tempLogoPath, response.data);
const existingLogoPath = findLogoPath(gameDir);