More progress

This commit is contained in:
WardPearce
2025-04-01 03:46:00 +13:00
parent bfcfe3bbb2
commit 9863cf74df
5 changed files with 28 additions and 25 deletions
+5 -1
View File
@@ -3,12 +3,13 @@ const https = require('https');
const HOST = 'localhost';
const PORT = 3000;
const MAX_REDIRECTS = 5;
const MAX_REDIRECTS = 10;
function setCorsHeaders(res) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', '*');
res.setHeader('Access-Control-Max-Age', '86400')
res.setHeader('Access-Control-Allow-Credentials', 'true');
}
@@ -86,6 +87,9 @@ const server = http.createServer(async (req, res) => {
)
};
options.headers.host = parsedTarget.host;
options.headers.origin = parsedTarget.origin;
// For POST and PUT methods, pass the body to the outgoing request
if (req.method === 'POST' || req.method === 'PUT') {
options.headers['Content-Length'] = Buffer.byteLength(body);