From 3b9789eeaa61f7c8f0f04e0c7a411b3b27572b84 Mon Sep 17 00:00:00 2001 From: WardPearce Date: Mon, 27 Jan 2025 20:09:39 +1300 Subject: [PATCH] Minor fixes to closing proxy request --- materialious/static/nodejs-android/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/materialious/static/nodejs-android/index.js b/materialious/static/nodejs-android/index.js index bed472ea..b1e2dfb1 100644 --- a/materialious/static/nodejs-android/index.js +++ b/materialious/static/nodejs-android/index.js @@ -2,7 +2,7 @@ const http = require('http'); const https = require('https'); const HOST = 'localhost'; -const PORT = 3000; +const PORT = 8888; const MAX_REDIRECTS = 5; function setCorsHeaders(res) { @@ -20,6 +20,7 @@ function fetchWithRedirects(targetUrl, options, redirectCount = 0) { const req = httpClient.request(targetUrl, options, (res) => { if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { if (redirectCount >= MAX_REDIRECTS) { + req.end(); return reject(new Error('Too many redirects')); } @@ -28,6 +29,7 @@ function fetchWithRedirects(targetUrl, options, redirectCount = 0) { const redirectUrl = new URL(res.headers.location, targetUrl); return resolve(fetchWithRedirects(redirectUrl, options, redirectCount + 1)); } catch (error) { + req.end(); return reject(new Error(`Invalid URL in redirect: ${error.message}`)); } }