From d6c5430e0c932dd4a64b7aeaa60186051a05144b Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Sun, 11 Jan 2026 17:05:21 +0000 Subject: [PATCH] Fix headless download --- packages/create/create.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/create/create.js b/packages/create/create.js index fe4318d7..69f17e7d 100755 --- a/packages/create/create.js +++ b/packages/create/create.js @@ -754,8 +754,8 @@ async function inquirerMissingArgs(args) { async function downloadLinuxServer() { let res = await fetch("https://factorio.com/get-download/stable/headless/linux64"); - const url = new URL(res.headers.location); // get the filename of the latest factorio archive from redirected url + const url = new URL(res.url); // The res is redirects, need final url const filename = path.posix.basename(url.pathname); const match = filename.match(/(?<=factorio_headless_x64_|factorio-headless_linux_)\d+\.\d+\.\d+(?=\.tar\.xz)/); if (!match || !match.length) { @@ -772,10 +772,7 @@ async function downloadLinuxServer() { if (await fs.pathExists(factorioDir)) { logger.warn(`setting downloadDir to ${factorioDir}, but not downloading because already existing`); } else { - await fs.ensureDir(tmpDir); - - // follow the redirect - res = await fetch(url.href); + await fs.emptyDir(tmpDir); logger.info("Downloading latest Factorio server release. This may take a while."); const writeStream = fs.createWriteStream(tmpArchivePath); @@ -794,8 +791,10 @@ async function downloadLinuxServer() { throw e; } - await fs.unlink(archivePath); + await fs.ensureDir("factorio"); await fs.rename(tmpFactorioDir, factorioDir); + await fs.unlink(archivePath); + await fs.rm(tmpDir); } } @@ -821,6 +820,10 @@ async function main() { .option("http-port", { nargs: 1, describe: "HTTP port to listen on [standalone/controller]", type: "number", }) + .option("download-headless", { + describe: "Download the latest headless release [standalone/controller] [linux only]", + type: "boolean", nargs: 0, + }) .option("host-name", { nargs: 1, describe: "Host name [host]", type: "string", })