测试js
This commit is contained in:
parent
1fdb2b3152
commit
146b064dfb
@ -4,7 +4,11 @@ import { dirname, join } from "node:path";
|
|||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.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 port = Number(process.env.PORT || 8787);
|
||||||
const upstreamBase = (process.env.BAISHUN_API_BASE || "https://api-test.global-interaction.com").replace(/\/+$/, "");
|
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();
|
res.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (req.url === "/" || req.url === "/baishun-game-test.html") {
|
const url = new URL(req.url || "/", `http://${req.headers.host || "127.0.0.1"}`);
|
||||||
const html = await readFile(htmlPath);
|
const pagePath = pagePaths.get(url.pathname);
|
||||||
|
if (pagePath) {
|
||||||
|
const html = await readFile(pagePath);
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
"Content-Type": "text/html; charset=utf-8",
|
"Content-Type": "text/html; charset=utf-8",
|
||||||
"Cache-Control": "no-store",
|
"Cache-Control": "no-store",
|
||||||
@ -75,6 +81,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.listen(port, "127.0.0.1", () => {
|
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}`);
|
console.log(`Proxy upstream: ${upstreamBase}`);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user