diff --git a/tools/baishun-game-test-server.mjs b/tools/baishun-game-test-server.mjs index 17111427..28f3b2a2 100644 --- a/tools/baishun-game-test-server.mjs +++ b/tools/baishun-game-test-server.mjs @@ -4,7 +4,11 @@ import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; const __dirname = dirname(fileURLToPath(import.meta.url)); -const htmlPath = join(__dirname, "baishun-game-test.html"); +const pagePaths = new Map([ + ["/", join(__dirname, "baishun-game-test.html")], + ["/baishun-game-test.html", join(__dirname, "baishun-game-test.html")], + ["/lucky-gift-test.html", join(__dirname, "lucky-gift-test.html")], +]); const port = Number(process.env.PORT || 8787); const upstreamBase = (process.env.BAISHUN_API_BASE || "https://api-test.global-interaction.com").replace(/\/+$/, ""); @@ -53,8 +57,10 @@ const server = http.createServer(async (req, res) => { res.end(); return; } - if (req.url === "/" || req.url === "/baishun-game-test.html") { - const html = await readFile(htmlPath); + const url = new URL(req.url || "/", `http://${req.headers.host || "127.0.0.1"}`); + const pagePath = pagePaths.get(url.pathname); + if (pagePath) { + const html = await readFile(pagePath); res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", @@ -75,6 +81,7 @@ const server = http.createServer(async (req, res) => { }); server.listen(port, "127.0.0.1", () => { - console.log(`Baishun game test page: http://127.0.0.1:${port}`); + console.log(`Baishun game test page: http://127.0.0.1:${port}/baishun-game-test.html`); + console.log(`Lucky gift test page: http://127.0.0.1:${port}/lucky-gift-test.html`); console.log(`Proxy upstream: ${upstreamBase}`); });